Wednesday, December 1, 2010

Command Line History Tricks

Command: !!

Usage: Repeats the last command from the history.

Example:

-bash-2.05b# date
Wed Dec  1 20:16:13 GMT 2010
-bash-2.05b# !!
date
Wed Dec  1 20:16:19 GMT 2010
-bash-2.05b#

Command: !character


Usage: Repeats the last command that begins with "character" from the history.

Example:
-bash-2.05b# pwd
/root
-bash-2.05b# date
Wed Dec  1 20:17:56 GMT 2010
-bash-2.05b# uptime
 20:18:00 up  8:52,  1 user,  load average: 0.10, 0.11, 0.09
-bash-2.05b# !p
pwd
/root
-bash-2.05b#

Command: history


Usage: Displays the commands recorded in the history.


Command: !N


Usage: Executes the command recorded in the history and identified by the number (N) specified.

No comments:

Post a Comment