(formerly "Solaris Survival Guide" by Mike Boldin, Niagara College, 2000-2005)
Version 1.2
Last modified on 2011/09/07 01:32:34 by
mboldin
The bash shell remembers all of the commands that you have previously typed in. You can use the up and down arrows to scroll through the history. Or you can type the history command and get a listing (you can pipe it through more or less), for example:
$ history | more ... 24 cat /etc/passwd 25 ls -l /etc 26 cd /etc ...
Then you can re-execute previous commands by copying and pasting with the mouse, or by typing an exclamation point (!, pronounced "bang") followed by the number of the command you want to repeat:
$ !25 ls -l /etc ...
Bash also remembers command-line arguments (also known as parameters.) !$ remembers the last argument of the previous command, and !* remembers all of the arguments of the previous command:
$ ls -l /etc ... $ cd !$ cd /etc ...