next up previous contents index
Next: The cd Command Up: Shell Commands Previous: Shell Commands   Contents   Index


The alias Command

The alias command is used to create aliases, as in the C-shell.

alias [word] [text]
The alias command causes word to be aliased to text. Whenever a command line beginning with word is typed, text is substituted. Arguments are either appended to the end, or substituted in if history characters are present in the text. With no argument, a list of the current aliases is displayed.

In the body of the alias text, any strings of the form !:number are replaced with the number'th argument of the actual command line. Note that when the alias is defined with the alias command, these strings must be quoted to prevent history substitution from replacing the !'s before the alias command can get to them. Thus the command

alias foo echo '!:2' '!:1'
causes ``foo bar baz"'' to be replaced with ``echo baz bar''. Other ! modifiers as described in the section on history substitution may also be used, always referring to the actual command line arguments given. If a command line starts with a backslash `\' any alias substitution is inhibited.


next up previous contents index
Next: The cd Command Up: Shell Commands Previous: Shell Commands   Contents   Index
Stephen R. Whiteley 2017-02-22