Previous topic |
Next topic |
Contents |
Contact z/OS |
Library |
PDF
Setting up an alias for a particular version of a command z/OS UNIX System Services User's Guide SA23-2279-00 |
|
If you tend to use a command with the same options every time,
you may want to set up an alias for the command with those particular
options. Let's take an example. The grep command searches
through files and prints out lines that contain a requested string.
For example:
displays all the
lines of file that contain the string hello. Normally, grep distinguishes between uppercase and lowercase letters; this
means, for example, that the search in the previous example does not display lines that contained HELLO, Hello, and so forth. If you want grep to ignore the
case of letters as it searches, you must specify the –i option,
as in:
This finds hello, HELLO, Hello, and so on.If you think you prefer to use the –i version of grep most of the time, you can define the alias:
From this point on, if you use the command:
it is automatically converted to:
and you get the case-insensitive version
of the command grep.As another example, the rm command to delete (remove) a file has an –i option
that prompts you to confirm the deletion. The file name and a question
mark are displayed. For example, if you entered rm -i file1 and file1 is in your working directory, you would see
the prompt:
before the system actually removes
the file. You then enter y (yes) or n (no)
in response. If you like this extra bit of safety, you might define:
After this, when you call rm, it automatically
checks with you before deleting a file, just to make sure that you
really want to delete it.It may seem odd to define an alias that has the same name as a command that is used in the alias, but this is so common that the shell checks specially for an alias of the same name, and does the correct thing. If you find yourself using the same option every time you call a command, you might consider creating an appropriate alias so that the shell automatically adds the option. Of course, the best place to define this alias is in your .tcshrc file; then the alias is set up every time you invoke the shell. |
Copyright IBM Corporation 1990, 2014
|