Shamelessly copied from this tiny twitter thread by Kristian Köhntopp
$ !keks
Search history for the last command starting with keks
$ !?keks
Search history for the last command containing keks
$ ^keks^cookie
Repeat the previous command, after replacing keks with cookie
$ !!
Repeat the previous command
$ !!:s/image/headers/
Repeat the previous command, after substitution of image with headers
$ !!:gs/image/headers/
Repeat the previous command, after substitution of image with headers on the whole command line
$ sudo !!
Repeat the previous command but prefix it with sudo (so much yelling!)
$ shopt -s histverify
Show result of above history expansion before exec.
$rm -rf keks
Starting a command with a space will prevent it from entering the history.
$ unset HISTFILE
unsetting HISTFILE or HISTFILESIZE will prevent the shell from logging commands
And of course, as mentioned later in that discussion:
Comments
Comments are closed.