San Diego State University logo

*Technical Briefs*
ROHAN help Files

----------------------------------------------------------------------

aliases

aliases are short names for long commands or lists of commands. You can then type the name of the alias instead of the commands. The alias can contain spaces, pipes, and anything else you can type on a command line. The syntax for alias is:

rohan% alias  aliasname  command

You can then type the name of the alias instead of the commands.

aliases can be used in the C and Korn Shells, but not in the Bourne Shell. Usage example for the C Shell:

rohan% alias  doit  '/usr/jones/bin/programclass'

Usage example for the Korn Shell:

rohan% alias  doit='/usr/jones/bin/programclass'

Each example tells the appropriate shell to run Jones' programclass, when you type doit. The difference in the two command lines is the equal sign in the Korn Shell example.

Notice: In the above usage examples, the single quotes are optional since the commands don't contain any spaces or special characters.

It is also possible to create an alias that stands for a list of commands. Each command should be followed by a semicolon and a space. For example:

rohan% alias  aliasname  'command;  command;  command'

This will now create an alias which will execute the listed commands.

Notice: Because certain characters (such as ;) have special significance to the shell, it is recommended that these commands be enclosed in single quotes. This is recommended any time you make an alias for a command or commands that has punctuation.

Other examples of the command:

alias a alias
This allows you to use a instead of typing the whole word alias.
alias doit
If you want to check the current value of an alias, enter alias followed only with a name previously given to an alias. This would give the value of doit.
If you want a list of all aliases that you have set in your shell, enter the command alias by itself and the system will list all the aliases you have created.

aliases you type directly to the shell are lost when you log out. If you want them to be available permanently, you must put the alias commands in your .login or .profile files.

If you want to remove an alias, use the unalias command. The following command line would remove doit.

rohan% unalias  doit

----------------------------------------------------------------------


BACK ROHAN Help Index | Academic Computing Handouts, Manuals, and Help Files

This page last modified: November 22, 2002
Send comments/suggestions about this web page to webmaster@rohan.sdsu.edu

SDSU Faculty and Students may send questions about software on ROHAN or ROHAN UNIX problems to problems@rohan.sdsu.edu