我想将简单的Ruby脚本及其输出保存在一个文件中。我知道jupyter-notebook是一个很好的工具。Ruby脚本可以通过使用iruby在jupyter中执行。但我不想用iruby。因为iruby不稳定,jupyter对我来说是过度设计的。
所以我正在寻找一种简单的方法。
hello.rb
puts "hello world"
2 + 3执行一些很好的命令
irbliketool hello.rb > output.txtoutput.txt会是这样的.
irb > puts "hello world"
hello world
=> nil
irb > 2+3
=> 5有什么好主意吗?
发布于 2018-05-11 21:47:13
您可以将文件传递给irb。
irb hello.rb > output.txt不完全相同的输出,但您也可以这样做:
cat hello.rb | irb > out.txthttps://stackoverflow.com/questions/50293709
复制相似问题