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 .sh_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 r, followed by a space, followed by the number of the command you want to use. Think of r as the redo command. 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; you can then
run the command with r.Another time-saver is to specify your shell prompt as:
in your .profile.
The shell prompt is then preceded by the number assigned to the command
in the command history file.This is how you use the command numbers to enter a command. To
repeat command number 14, enter:
The shell displays
the original command 14 in the output area of the screen and then
runs it. If you get another error, you can correct it, and then compile
again with another r 14.
You can perform the operation many times, but you have to type the
original only once.If you type r 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 example, let's 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 r can search for aliases as well as normal commands. r 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 r without a number after it, the shell repeats the most recent command. |
Copyright IBM Corporation 1990, 2014
|