Specify A Command From History

One can specify an event from their history on the input line to repeat it.

The easiest way to specify an event from history is to use the up and down arrow keys. The up arrow key (<>) steps backwards through command events and the down arrow key (<>) steps forward through events. When an event is on the input line it can be edited it as if it were on the command line or type <Enter> to run it; it then become the most recent event in shell history.

Example…
Specify the second-to-last command…
$ <> <>

To specify an event by its number enter an exclamation point (!, a.k.a a “bang”) followed by the event number.

Example…
Run history event number 1…
$ !1 <Enter>

Observe event number “!” is the last event thus typing !! is another way to rerun the last command.

== Alonzo Fretwell holds a BS in Computer Science which he earned in 1997 from the Howard R. Hughes College of Engineering located on the campus of the University of Nevada, Las Vegas. Mr. Fretwell also blogs about Linux and iPhones at http://alonzofretwell.com