Bash is not the only programming language. The most important it’s a shell. When you run a terminal, you get a bourne-again Shell. And it has special shortcuts and predefined special variables. For example,
$? contains the last exit code,
$PS1 is a template of Bash prompt.
But now we’ll talk about “bang” shortcuts.
Execute last command:
Execute the most recent command that starts with ‘top’ (e.g.
Displays the command that !top would run (also adds it as the latest command in the command history):
Execute the last word of the previous command (same as Alt + ., e.g. if last command is ‘ cat tecmint.txt ‘, then !$ would try to run ‘ tecmint.txt ‘):
Displays the word that !$ would execute:
Displays the last word of the previous command:
Displays the last word that !* would substitute: