1. Home
  2. Computing & Technology
  3. Ruby

Using the Command Line

By , About.com Guide

6 of 10

Use Pipe Characters to Redirect Output

Using the pipe characters is an important skill to master, as these characters will alter the input or output of a Ruby script. In this example, the > character is used to redirect the output of test.rb to a text file called test.txt instead of printing to the screen.

If you open new test.txt file after you run the script, you'll see the output of the test.rb Ruby script. Knowing how to save output to a .txt file can be very useful. It allows you to save program output for careful examination or to be used as input to another script at a later time.

C:\scripts>ruby example.rb >test.txt
Explore Ruby
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Ruby
  4. Tutorials
  5. Using the Command Line

©2009 About.com, a part of The New York Times Company.

All rights reserved.