Shorthand to get the last argument of the previous command

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.

Last Updated: 2024-04-18

When you're working interactively with the command line, how do you get the last argument of the previous command? Here's how:

!!$

Here's an example of how you might use this:

git diff --since="2 weeks ago"
# Open up gitk using the same option
gitk !!$ # i.e. gitk --since="2 weeks ago"