![]() |
Computer Systems Lab CS1000 |
![]() Wiscinfo |
![]() CS Home |
![]() CSL |
![]() CS1000 |
![]() Feedback |
A pipe connects two simultaneously running programs by making the output of the first program the input of the second. For example, the program more will show you a file a page at a time. You might use it like this:
vega1% more longfile
Now, let's suppose that your prog1 program is spewing out loads and loads of output. To see one screen at a time, do the following:
vega1% prog1 | more
This pipes the output of prog1 through more. You may connect any number of programs using pipes, and you may combine the I/O redirection you already know with the pipes. Take for example the program tee, which feeds its input to its output while at the same time copying the same input to whatever file argument you give it. Thus you put something in a file and see it on your screen at the same time. For example:
vega1% prog1 < data | tee results | more
This will run prog1, take its input from data, send the output on to tee, which copies the output into results, and sends it on to more to be inspected at your terminal, since all more does is show you its input one page at time. Pipes are commonly used with filters, as is shown in a later section.