Skip to main content

13.6) Complex Pipe Example


Try for example using the pipe command '|' to join a cat command with grep commands and a redirection '>':

cat file7 | grep 3 | grep 6 > out.file7

The name 'out.file7' can be any name. I could have called it anything, like 'output1' and it would have mad a file called 'output1' with the results in it. I use the name starting with 'out' to remind me that it is an output of something and then '.file7' just as a numbering.

As you progress with Unix, you will see that pipes are one of the most powerful commands that provides that essential joining up of the modular nature of Unix commands.

If we return to the example of the input file, then what if one of the input files had spaces as in:

‘JJP =    800’

Then it would be missed with the command we used before:

grep ‘JJP=800’ *