Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > shell/filterライブラリ > Shell::Filterクラス > |
self | filter -> object[permalink][rdoc]パイプ結合を filter に対して行います。
使用例
Shell.def_system_command("tail")
Shell.def_system_command("head")
Shell.def_system_command("wc")
sh = Shell.new
sh.transact {
i = 1
while i <= (cat("/etc/passwd") | wc("-l")).to_s.chomp.to_i
puts (cat("/etc/passwd") | head("-n #{i}") | tail("-n 1")).to_s
i += 1
end
}