Command History

You can recall commands you have used before, even in previous sessions.




Recall previous command.


Recall next command.


Show the last 100 commands.


Run the last command.


Run a specific previous command: the nn command in the commands history list.


Run the nnth previous command.

For example, entering !‑3 runs the third from last command in the commands history list.


Run the most recent command that starts with str.


Run the most recent command containing str.

You may omit the trailing ?, if a new line follows str immediately.


Repeat the last command, replacing str1 with str2.

Command Reuse

You can combine word designators with history commands to refer to specific words used in previous commands.

Words are numbered from the beginning of the line with the first word being denoted by 0 (digit zero).

Use a colon (:) to separate a history command from a word designator.

For example, you could enter !!:1 to refer to the first argument in the previous command.

In the command "show interfaces", the interfaces is word 1.

Word Designator



The operation word.


The nth word.


The first argument; that is, word 1.


The last argument.


The word matched by the most recent \?str\? search.

Immediately after word designators, you can add a sequence of one or more of these modifiers, each preceded by a colon:




Print the new command, but do not execute.


Replace str1 with str2 in the first occurrence of the word, to which you refer.


Apply changes over the entire command.
Use this modified in conjunction with s, as in gs/str1/str2.