DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Commands revisited: pipes and redirection

Using pipes to build your own utilities

You can use the pipe symbol (|) on a UNIX system to make the output of one command the input of another. To do this, you type the command you want to generate the input, a pipe symbol, the command you want to read the input, and then press <Enter>. You can use pipes to put together as many commands as you like.

grep engr employees | sort | lp

Earlier in this chapter, you learned how to print a directory listing by typing:

l > filelist
lp filelist

Doing this with a pipe is even faster:

l filelist | lp

Another way of using a pipe is to put long output through the more command.

l /etc | more

Try using a pipeline to print a list of the files in your home directory:

  1. If you are not already in your home directory, go there by typing cd and pressing <Enter>.

  2. Type l | lp and press <Enter> to send a long listing straight to the printer.

Next topic: Summary
Previous topic: Appending one file to another

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 03 June 2005