Command line usability basics: Pipes

Apr 3, 2007 - 1 Comment

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.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: OSXDaily in Command Line, How to, Mac OS X, Tips & Tricks

One Comment

» Comments RSS Feed

  1. kering says:

    usefull commands, thanks

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates