graphics\overbutt.gifCombining commands with pipes

You can combine commands using pipes (|). Pipes use the output from the first command as input for the second command, and the output from the second command as input for the third command, and so on. The last command output is displayed on the screen. You can redirect the final output to a file using standard output redirection. For information about redirecting output, see "Redirecting input and output."

For example, you can use the Concatenate command (cat) to read the contents of a file called testfile, then copy testfile to the directory called tests, and finally run the Word Count command (wc) to view the number of lines, words, and characters in testfile. The output displayed indicates that there are 2 lines, 16 words, and 75 characters in testfile.

Mabel~:$ cat testfile | cp testfile tests | wc testfile

 2 16 75 testfile

To combine commands

1. At the command line, type,

<command1> | <command2> | <command3>

2. Press ENTER.

graphics\nicon.gif Notes