Command line usability basics: Pipes
Obviously we cover the Mac OS X command line relatively often here at OS X Daily, but our recent article Command Line usability basics: Redirection probably should have included a bit about pipes as well. Pipes allow you to direct the output of one command into the input of another, and knowing how and when to use them are vital to effective command line usage. Without further ado, here’s some information on command line pipes and how to use them:
The pipe symbol looks like |, (it’s the same key as your \ key, if you’re confused), and is immensely useful when you’re working in the command line. Here’s some examples:
ls -la | more
This takes the list command (with long and all flags) output and ‘pipes’ it through to the more command, allowing you to view the output one page at a time.
ps aux | grep user
This command takes the output of the process command, and reports back only process instances belonging to ‘user’
You can use pipe with virtually anything, so use your imagination.