1. !! Repeats the previous command:
   $ ls
   $ !!
   ls
  1. !n Repeats the command at position n in the history list:
$ history
1 ls
2 pwd
3 echo "Hello"
$ !2
pwd
  1. !-n Repeats the command that was executed n commands ago:
$ ls
$ pwd
$ echo "Hello"
$ !-3
ls
  1. !string Repeats the most recent command starting with string:
$ ls -l
$ pwd
$ !ls
ls -l
  1. !?string Repeats the most recent command containing string:
$ ls -al
$ echo "Test"
$ !?al
ls -al
  1. ^old^new Repeats the previous command, but substitutes old with new:
$ echo "Hello world"
$ ^world^everyone
echo "Hello everyone"
Hello everyone
  1. !$ Refers to the last argument of the previous command:
$ mkdir new
$ cd !$
cd new
  1. !* Refers to all the arguments of the previous command:
$ touch file1.txt file2.txt file3.txt
$ chmod o+r !*
chmod o+r file1.txt file2.txt file3.txt
  1. !:^ Refers to the first argument of the previous command:
$ cp file1.txt /some/directory/
$ echo !:^
echo file1.txt
file1.txt
  1. !:n-m Refers to a range of arguments to the previous command:
$ cp file1.txt file2.txt file3.txt /some/directory
$ echo !:1-2
echo file1.txt file2.txt
file1.txt file2.txt
  1. !!:p Print the last command without executing it:
$ echo "Hello, World!"
$ !!:p
echo "Hello, World!"