Linux: Command Recall

Quick Tip: Command recall is a macro-like function of bash, which replaces “!!” with the last executed command.
This is useful if you notoriously forget to sudo something or try to execute a script which doesn’t have the ‘x’ flag set.

Examples:

~$ apt-get install bc
-----> no sudo
~$ sudo !!
-----> this works


~$ ./script.sh
-----> not executable
~$ chmod +x !!
-----> this works

But there is more: !!* returns the arguments, !-n returns the nth last command, … the options are endless! Even Regular Expressions can be applied to replace text or find a certain command!