Skip to main content

13.4) Pipe Example


To illustrate pipes, now instead of having the results printed to the screen we can feed the results back into another grep command to isolate all of those lines with ‘3’ by typing:

grep ‘5’ file7 | grep 3

The quotes are optional around the ‘5’ because it is a simple character. Searching for words with spaces or special characters will need quote around them. The result from the command above is:

3       4       5
34      4       56

So it is important to realize that Unix will print results to the screen or through redirection (‘>’) to a file, or through a pipe (‘|’) to another Unix command.