0

我想在 Ruby 中执行以下操作:

cat </dirpath/file.*> | grep <pattern> | grep <pattern2> | cut <options> > <path>/output.txt
4

1 回答 1

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)}
于 2013-09-25T21:28:13.683 回答