You have already seen that the shell keeps the history of the commands you type. The history command can be used to list previously used commands. You can use an option to list a particular number of previous commands. To list the three previous commands, you use:
$ history -3 457 cat /etc/profile 458 more /home/boota/.profile 459 ls -l /etcmore $
To list a range of commands, you provide the starting and ending numbers of the commands in the history.
$ history 451 453 451 date 452 ls 453 mkdir tmp
To reexecute a previous command, you use the r command with the command number. The r command executes a numbered command from the history and prints the command as well as its result on stdout . In the next example, the command executed is the date command.
$ r 451 date Wed Oct 13 22:33:17 EDT 1999 $
Top |