Pipes
I mentioned previously that Unix uses lots of text files, which are easy to create and manipulate. Unix has a variety of commands to manipulate text files. The way to move text between these commands is with pipes. The pipe symbol is the vertical bar (|) above your Enter key.
For example, suppose you have a text file full of email addresses, with one email address per line. Suppose it’s named “emails.txt” and it’s on your Desktop.
To view the emails, type the following command in the Terminal:
cat ~/Desktop/emails.txt
To view the emails sorted alphabetically, type the following:
cat ~/Desktop/emails.txt | sort
The pipe causes the output of the cat command to be fed into the sort command, then outputted to the screen. You can tack on as many pipe commands as you need.
To view the emails sorted alphabetically and with a prompt between each page, type:
cat ~/Desktop/emails.txt | sort | more
The list of emails “flows” from the cat command to the sort command to the more command, as if going through water pipes.

January 2nd, 2007 at 3:38 am
Although you can certainly pipe a cat into sort as you’ve shown, it’s easier to type and more efficient to simply put the filename after sort. In the manner you’ve done it, you’ve triggered my “Useless Use of Cat Award” response. Too bad.
January 2nd, 2007 at 9:53 am
Randal, you seem to have missed that the post was about using the pipe, not about cat or sort, but you are correct.
January 18th, 2007 at 1:42 am
Perhaps next it would be good to explain the tee command as a continuance to the lesson on pipes.
I’m glad to see a site to extoll the virtues of the unix base of OS X to the masses.
March 8th, 2007 at 12:26 pm
Is FreeMacUnix dead?
July 9th, 2007 at 3:44 pm
Hey! Where’s the next lesson? Don’t stop!