Defines or displays aliases.
The alias command creates or redefines alias definitions or writes existing alias definitions to standard output.
If no flags or parameters are supplied, all existing alias definitions are written to standard output. You can display a specific alias definition by using the AliasName parameter.
Create a new alias by using the AliasName=String parameter pair. When the shell encounters an alias on the command line or in a shell script, it substitutes the definition supplied by the string. The String variable can contain any valid shell text. Enclose the value of the String variable in single quotes if the string contains spaces. If the AliasName parameter is not a valid name, the alias command displays an error message.
If you specify the -t flag, the shell displays aliases that are tracked. A tracked command uses the full path name of the command. A tracked command can become undefined when the value of the PATH environment variable is reset, but aliases created with the -t flag remain tracked.
If you specify the -x flag, the shell displays aliases that are exported. An exported alias is active in all shells.
An alias definition affects the current shell environment and the execution environments of any subshells. The alias definition affects neither the parent process of the current shell nor any utility environment invoked by the shell.
Item | Description |
---|---|
-t | Sets or displays all existing tracked aliases. If this flag is used with the AliasName parameter, the new alias is tracked and the alias definition includes the full path name obtained by doing a path search. When the value of the PATH environment variable is reset, the alias definition becomes undefined but remains tracked. |
-x | Displays all existing exported alias definitions. If this flag is used with the AliasName parameter, the new alias is exported. Exported alias are not defined across separate invocations of the shell. You must put alias definitions in your environment file to have aliases defined for separate shell invocations. |
The following exit values are returned:
Item | Description |
---|---|
0 | Successful completion. |
>0 | One of the specified alias name did not have an alias definition, or an error occurred. |
alias ls='ls -CF'
alias r='fc -s'
alias du=du\ -k
alias psc='ps -ef | grep Dee'
alias -t ls
The screen displays ls=/usr/bin/ls.Item | Description |
---|---|
/usr/bin/ksh | Contains the Korn shell alias built-in command. |
/usr/bin/alias | Contains the alias command. |