Useful Bash variables
Posted on
GNU Bash has a few two letter variables that may be useful when typing on the terminal.
!!: the text of the last command
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.
Conclusion
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.