10 Good Unix Command Line Usage Habits and Tips

Aug 24, 2010 - 4 Comments

Terminal in OS X If you use the command line frequently, chances are you may have some bad command line habits. IBM’s DeveloperWorks site has posted 10 good UNIX usage habit tips, some of them are just pretty handy tricks in general and if you’re new to the Mac OS X Terminal, you’ll probably learn something since practically all of them work within the Mac OS X command line.

We’ve got the full list of 10 good habits below, but here’s one of my personal favorites since it hit home with my command line activities:

* Change the path to unpack something into rather than moving the archive file itself, in this example by using the -C flag with the tar command:

tar xvf -C path/to/unpack newarc.tar.gz

I’m certainly guilty of moving archives around, but that’s partially because I like to keep all of them in a central location. But if you’re going to just delete the archive anyway, there’s no point in moving the archive file around just to unpack it. Save yourself the keystrokes.

Here’s the full list of 10 tips in the IBM DeveloperWorks article:

  • Make directory trees in a single swipe
  • Change the path; do not move the archive
  • Combine your commands with control operators
  • Quote variables with caution
  • Use escape sequences to manage long input
  • Group your commands together in a list
  • Use xargs outside of find
  • Know when grep should do the counting — and when it should step aside
  • Match certain fields in output, not just lines
  • Stop piping cats

Check them out: IBM DeveloperWorks: Learn 10 good UNIX usage habits


Related articles:

Posted by: David Mendez in Command Line


» Comments RSS Feed

  1. devilspride says:

    tar -zxvf path/to/gzippedtarfile -C path/to/unpack

    z will use gzip to uncompress it

  2. motoko says:

    tar xvf -C path/to/unpack newarc.tar.gz

    but the newarc is gzipped…tar can uncompress a gzipped file?

    • motoko says:

      on 10.5.8 works:

      tar xvf path/to/gzippedtarfile -C path/to/unpack

      p.s.=I didn’t know that the z option can be omitted

  3. Woodgie says:

    Absolutely excellent, thank you!

Leave a Reply


Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

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

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site