Useful Bash variables
Posted on
November
12, 2020
GNU Bash has a few two letter variables that may be useful when typing on the terminal.
The !!
variable refers to the previous command, and I find
useful when following chains for symlinks:
It is also useful when you forget to prefix sudo
to a command that requires
it:
Bash prints the command expansion before executing it, so it is better for you to follow along what it is doing.
The $_
variable will give you the most recent parameter
you provided to a previous argument, which can save you typing sometimes:
I wouldn’t use those in a script, as it would make the script terser to read, I find those useful shortcut that are handy when writing at the interactive terminal.