Bash history shortcuts

Many people who sit with me at a computer have questions about the strange incantations that I type into the terminal. I often use shell techniques like grabbing the last argument to the previous command:

$ ls ~/src/atlassian/confluence/trunk
$ cd !$

Or using the output of the last command as an argument to this one:

$ find . -name
$ vi `!!`

Two weeks ago, if you wanted to understand how this works, I would have referred you to the man page, and showed you the two or three tricks I know. But now, Allan Odgaard has written a thorough and very readable article on the subject: Working with history in bash.

I won’t try to summarise it here. If you’re interested in improving your bash fu, be sure to read it.

Portrait of Matt Ryall

About Matt

I’m a technology nerd, husband and father of four, living in beautiful Sydney, Australia.

My passion is building software products that make the world a better place. For the last 15 years, I’ve led product teams at Atlassian to create collaboration tools.

I'm also a startup advisor and investor, with an interest in advancing the Australian space industry. You can read more about my work on my LinkedIn profile.

To contact me, please send an email or reply on Twitter.