You can use the built-in alias command in the POSIX shell sh to redefine shell commands. However, you may not use it to redefine reserved words. You can use the alias command to define and export alias variables as well as to write them to standard output. The unalias command is used to delete alias variables. Exported alias variables remain effective for procedures which are called by name. However, they must be reinitialized for any new, explicit calls to the POSIX shell. For the use of alias variables see the section “Aliasing”.
Syntax
Format 1: | alias[ -t][ name] |
Format 2: | alias[ -x][ name[=value]]... |
No option specified alias with no arguments writes the list of aliases in the form name=value to standard output.
is used to set and list alias variables which possess a path specification (tracked alias). The value of this type of variable consists of the full path name as far as name. While changing the value of PATH invalidates the value definition, name retains the path specification. If option -t is not set then the pair name=value is output for every name which has no associated value in the argument list. -t not specified: |
A space at the end of value causes the next word in the command line to be checked for alias substitution.
is used to set and output exported alias variables. An exported alias variable is defined for procedures which are called by name. |
Exit status
The exit status is non-zero if no value is defined for name. |
Variable
PATH Default variable for the POSIX shell. The absolute path name of the directories in which the POSIX shell is intended to search for commands is assigned to the variable. |
Locale
The following environment variables affect the execution of alias: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments). LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example
You can use the following aliases to simplify the ls command:
|
See also
unalias |