Run a Previous Command Using Numbers


![##]

When you run history, it automatically places a number in front of every previous command. If you'd like to run a previous command and you know the number that history has assigned to it, just enter an exclamation point immediately followed by that command's history number, and it will run again.

$ pwd /home/scott $ whoami scott $ !499 pwd /home/scott 


If you're unsure about the number, run history again to find out. Be aware that the pwd command in this example was number 499 the first time, but after I ran it again using !499, it became 498 because it was pushed down on the list by my new command.



Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net