UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: :Chapter 5
The C Shell
Next: Reference: bg
 

alias

alias [name [command]]

Assign name as the shorthand name, or alias, for command. If command is omitted, print the alias for name; if name is also omitted, print all aliases. Aliases can be defined on the command line, but they are more often stored in .cshrc so that they take effect after login. (See the section "Example .cshrc File" earlier in this chapter.) Alias definitions can reference command-line arguments, much like the history list. Use \!* to refer to all command-line arguments, \!^ for the first argument, \!$ for the last, etc. An alias name can be any valid Unix command; however, you lose the original command's meaning unless you type \name. See also unalias.

Examples

Set the size for xterm windows under the X Window System:

alias R 'set noglob; eval `resize`; unset noglob'

Show aliases that contain the string ls:

alias | grep ls

Run nroff on all command-line arguments:

alias ms 'nroff -ms \!*'

Copy the file that is named as the first argument:

alias back 'cp \!^ \!^.old'

Use the regular ls, not its alias:

% \ls


Previous: Reference: :UNIX in a Nutshell: System V EditionNext: Reference: bg
Reference: :Book IndexReference: bg

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System