1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

Using the Command Line


8 of 10

Funnel Output and Input Between Scripts

The pipe character, | will funnel the output from one script to the input of another script. It's the equivalent of funneling the output of a script to a file, then funneling the input of a second script from that file. It just shortens the process.

The | character is useful in creating "filter" type programs, where one script generates unformatted output and another script formats the output to the desired format. Then the second script could be changed or replaced entirely without having to modify the first script at all.

C:\scripts>ruby example1.rb | ruby example2.rb
  1. About.com
  2. Technology
  3. Ruby
  4. Beginning Ruby
  5. Using the Command Line

©2014 About.com. All rights reserved.