Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Retrieving commands from the history file z/OS UNIX System Services User's Guide SA23-2279-00 |
|
The shell records each command that you enter in a file under your home directory. This file is called the history file; its name is .history. If you enter the command:
the shell displays
the current contents of your history file. Each command is numbered.You can rerun any of the commands in your history file by typing !, followed by a space, followed by the number of the command you want to use. For example, suppose that you are a programmer and you enter a
complicated command to compile part of a program. The program contains
a syntax error, so you call a text editor to edit the source code
and correct the problem. Now you want to run the same compile command
on the corrected program. You may save yourself a good deal of typing
by using:
to find out the number of the previous compile command and
then running the command with !. For example, if the history
file shows you that the command you want to run is number 44, you
would type:
to run the previous compile command.Another time-saver is to specify your shell prompt as:
in your .tcshrc file.
The shell prompt is then preceded by the number assigned to the command
in the command history file.If you type ! followed by a space, followed by a string
of characters (not beginning with a digit), the shell checks backward
through the history file and runs the most recent command that begins
with the given string. For instance, look at the compilation example.
Suppose you are using the c++ command to compile your program.
Then:
looks back through the history and runs the
most recent c++ command. You do not even have to check on
the number of the command you want to enter. The shell displays the
selected command in the output area of the screen and then runs it.This backward-search feature of ! can search for aliases as well as normal commands. ! searches for the beginning of the command line as you typed it, not the way that the line looked after the alias was replaced. If you enter !! without a number after it, the shell repeats the most recent command. |
Copyright IBM Corporation 1990, 2014
|