Databases Reference
In-Depth Information
Listing the Command History
You can use the history command to display commands that the user previously entered:
$ history
Depending on how many commands have previously been executed, you may see a lengthy stack. You can
limit the output to the last n number of commands by providing a number with the command. For example,
the following query lists the last five commands that were run:
$ history 5
Here is some sample output:
273 cd -
274 grep -i ora alert.log
275 ssh -Y -l oracle 65.217.177.98
276 pwd
277 history 5
To run a previously listed command in the output, use an exclamation point ( ! ) (sometimes called the bang)
followed by the history number. In this example, to run the pwd command on line 276, use !, as follows:
$ !276
To run the last command you ran, use !! , as shown here:
$ !!
Searching in Reverse
Press Ctrl+R, and you're presented with the Bash shell reverse-search utility:
$ (reverse-i-search)'':
From the reverse-i-search prompt, as you type each letter, the tool automatically searches through previously
run commands that have text similar to the string you entered. As soon as you're presented with the desired command
match, you can rerun the command by pressing the Enter or Return key. To view all commands that match a string,
press Ctrl+R repeatedly. To exit the reverse search, press Ctrl+C.
Setting the Command Editor
You can use the set -o command to make your command-line editor be either vi or emacs . This example sets the
command-line editor to be vi :
$ set -o vi
Now, when you press Esc+K, you're placed in a mode in which you can use vi commands to search through the
stack of previously entered commands.
 
Search WWH ::




Custom Search