4 Tips from the Unix Greybeards

So I’ve been using Unix for a number of years, and think of myself as relatively competent in using Posix based operating systems. I’ve recently had the great pleasure of working with a few guys who’ve been using Unix for longer than I’ve been able to read, and I’ve been able to add a couple of more commands that are extremely useful. It’s always great to watch a master using their tools, and to learn while working with them.

The commands below are a mix of ones that I’ve just learnt. I probably should have known these already – but they are lovely, and you need to add them to your arsenal.

  1. !!
  2. locate
  3. look
  4. xargs

    1. !!

    re-execute the last command.

    !! also has friends like !COMM where it will execute the last command in your history that starts with COMM.
    e.g.
    !find will re-execute your last find.

    2. locate

    With a locate database setup, locate is magic. Think spotlight for the commandline.

    3. look

    The man page for look talks about it searching a file, then mentions about the default location being /usr/share/dict/words. The default location is the key for the best usage. It’s a great little dictionary for looking up how to speel words.

    4. xargs

    The most masterful developers that I work with have advanced beyond xargs to the next level, but for people continuing on their pathway to true unix mastery, xargs is a great tool to add in.

    I commonly end up using variations of find and xargs together to search the contents of files, or to find out information about a project. If nothing else, the command:find . -name "*.java" |xargs wc -l | sort is your friend.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>