z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Editing commands from the history file

z/OS UNIX System Services User's Guide
SA23-2279-00

Suppose that you have a sequence of source files named file1.c, file2.c, file3.c, and so on that you want to compile with similar c89 commands. This situation is a little different from the one discussed in the previous topic. You do not want to rerun the same command for each file; the command has the same form each time, but you have to specify in a new file name each time.

You can still do this using the history file. The command:
r old_string=new_string command
runs a previous command but replaces the first occurrence of the old string with the new string. For example, suppose you compile file1.c with:
c89 options file1.c
Then the command:
r file1=file2 c89
tells the shell to search back for the most recent c89 command and change file1 to file2. The shell makes this change, and then displays and runs the modified command.
r file2=file3 c89
performs the same kind of operation, changing file2 in the previous command to file3 and then going ahead with the compilation. This saves you the trouble of retyping all the options for the command.
Entering alias displays all the currently defined aliases. You will see a number of aliases that you didn't set up; for example:
history="fc –l"
The history command is actually a predefined alias for the fc command with the –l option. The fc command is used to display and edit commands in the history file. Generally, it is easier to remember to type history, so the shell predefines this alias.

If you have displayed the predefined aliases, you probably noticed that r is also a predefined alias. It also stands for a version of the fc command. As with history, the r alias was created because it's easier to use and read than the straight fc command. For full details about fc, see the fc command description in z/OS UNIX System Services Command Reference.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014