History recall allows a previous statement to be quickly recalled and re-executed. It's a very fast shorthand, especially in the edit/compile/debug loop or to fix a typo. For convenience, ! is taken as an ordinary character if followed by white space, =, ~ or (.
If you want, you can choose different characters to introduce history references by changing the histchars variable.
Command | Meaning |
---|---|
!! | Last command |
!^ |
First argument word of last command |
!$ |
Last word of last command |
!* |
All arguments of last command |
!n |
Command n |
!-n |
nth command from the last, counting the immediately preceding command as !-0. |
!str |
Last command starting with str |
!?str? |
Last command containing str |
%str1%str2% |
Substitute str2 for str1 in last command. Recognized only at the beginning of the command line. |
histchars variable
Command completion
Filename completion
Command line editing
Tutorial: History
Tutorial: Filename completion
Tutorial: Command line editing