Name

alias, unalias - Alias or unalias command names

Syntax

alias [ name value ]
unalias name

Description

Without arguments, alias displays a list of the currently defined aliases. With arguments, alias associates name with the following value. The shell applies all transformations on the command line, notably the value assigned to the alias. Therefore, care must be taken when using alias so that the resulting value is stored as desired.

Example:

alias ls ls -F alias bye "echo It's \$date[4]; logout"

Whenever “ls” is entered, the shell expands it to “ls -F”. In the second example, “bye” is replaced by two commands. Remember that values assigned to aliases pass through all transformations twice: once when the alias is defined, and a second time when the alias is actually used. This includes character escaping, control character insertion, and variable expansion. See csh(C) for a dissertation on avoiding variable expansion when it isn’t desired.

Note that alias only affects the very first argument. If you typed the command “echo bye” you would see “bye” printed on your screen, not “logout”.

Argument Insertion


Alias values can contain special characters that indicate where command line arguments should be inserted. They are:

!^

Inserts the first argument

!$

Inserts the last argument

!*

Inserts all arguments

Here’s an example:

alias test "echo !\^"

Note: The caret character denotes special control code insertion. To include the caret literally, it has to be escaped with a backslash.

Entering “test” followed by one or more arguments causes the shell to first replace it with the “echo” command, and then takes the first argument following “test” and makes it the only argument to the “echo” command. Example:

test fizbin data compression fizbin

Alias substitutions may contain multiple argument insertion sequences, and the new command line will be built using the appropriate arguments from the original command line.

Changing and Removing Aliases


Old aliases can be changed with the alias command by reentering them with new values.

To remove an alias, use unalias followed by one or more alias names.

See Also

csh(C)