Ruby 2.6.0 リファレンスマニュアル > ライブラリ一覧 > shell/filterライブラリ > Shell::Filterクラス > |

instance method Shell::Filter#|

self | filter -> object[permalink][rdoc]

パイプ結合を filter に対して行います。

[PARAM] filter:
Shell::Filter オブジェクトを指定します。
[RETURN]
filter を返します。

使用例

require 'shell'
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
}