我想在Ruby中执行以下操作:
cat </dirpath/file.*> | grep <pattern> | grep <pattern2> | cut <options> > <path>/output.txt
答案 0 :(得分:2)
Dir.grep("/dirpath/file.*")
.map{|f| File.read(f)}
.join($/)
.grep(pattern)
.grep(pattern2)
.slice(options)
.tap{|s| File.write("path/output.txt", s)}