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.
re-execute the last command.
!! also has friends like !COMM where it will execute the last command in your history that starts with COMM.
!find will re-execute your last find.
With a locate database setup, locate is magic. Think spotlight for the commandline.
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.
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.