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 ConfluenceActionSupport.properties
$ 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 technology products that make the world a better place. In 2021, I started Mawson Rovers to develop robotics and software for space exploration. Prior to this, I led product teams at Atlassian to create collaboration tools for 15 years.

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.

blog@mattryall.net