If you can see this check that
| next section | up | prev page | next page |
You have seen how to use the > symbol to redirect output from standard output to a named file, and you have used the >> symbol to redirect output and append it to a named file without overwriting that file. However, by using what is termed a pipe, output from one command can be sent directly to another command as input. A pipe can link any two programs, provided the first program writes its output to stdout and the second program reads its input from stdin. The pipe symbol is represented as a (|). Its general syntax is as follows:
command1 | command2
command1 is the first command in the pipeline whose output is piped through the | symbol as input to command2. For example, suppose you want to know how many lines 2 of your file contain when combined together. You could do the following:
% cat file1 file2 > sample_file % wc -l < sample_file 121With a pipeline, these two commands can be combined into a single line:
% cat file1 file2 | wc -l 121
As we can see, using pipes eliminates the need for temporary intermediate files. Pipes can be used in many instances. For example, the following command would send a long listing of your directory to the printer.
% ls -l | lpr
| Tutlinks: | intro1 intro2 wildcard permission pipe vi essential admin net fwall DNS diag Apache1 Apache2 MySQL1 MySQL2 |
| Useful: | Quiz Forums |
| Site Links: | XMLZoo ActiveSQL ProgZoo SQLZoo |