After it is
recalled, you can modify the command line, as described earlier.
To view your history list, use the history command. Type the command without options or followed
by a number to list that many of the most recent commands. For example:
$ history 8
382 date
383 ls /usr/bin | sort -a | more
384 man sort
385 cd /usr/local/bin
386 man more
387 useradd -m /home/chris -u 101 chris
388 passwd chris
389 history 8
A number precedes each command line in the list. You can recall one of those commands using an
exclamation point (!). Keep in mind that when using an exclamation point, the command runs
blind, without presenting an opportunity to confirm the command you??™re referencing. There are
several ways to run a command immediately from this list, including:
!n??”Run command number. Replace the n with the number of the command line, and
that line is run. For example, here??™s how to repeat the date command shown as command
number 382 in the preceding history listing:
$ !382
date
Thu Oct 26 21:30:06 PDT 2008
!!??”Run previous command. Runs the previous command line. Here??™s how you??™d
immediately run that same date command:
$ !!
date
Thu Oct 26 21:30:39 PDT 2008
52
Linux First Steps Part I
!?string???”Run command containing string.
Pages:
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195