DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

alias(C)


alias, unalias -- create, display, or delete alias definitions

Syntax

alias [command[=string]] ...

unalias command ...

unalias -a

Description

alias creates, redefines, or prints alias definitions. An alias defines the string that is to replace a command string when it occurs in input. An alias, once defined, is recognized by the current shell and all its subshells that are subsequently created.

If string contains spaces, these must be quoted using a backslash ``\'' or the entire string must be enclosed in quotes.

If only the name of a command is specified, alias writes the alias definition (if any) for that command to the standard output.

When invoked without any arguments, alias prints all currently defined aliases.

unalias removes the definitions for all specified commands for the current shell. The -a option causes all alias definitions to be removed.

To invoke a command without it being aliased, escape it using a backslash ``\'' or quotes.

Exit values

alias and unalias return the following values:

0
successful completion

>0
one of the specified operands was not associated with a valid alias definition, or an error occurred

Examples

Redefine ls(C) to format its output into columns and indicate file type:

alias ls='ls -CF'

Invoke ls without the alias:

'ls'

Create a command to invoke the previous entry in the history list file (note the escaped space before -s):

alias r=fc\ -s

Change du(C) so that it always uses 1KB units for its output:

alias du="du -k"

Alter nohup(C) so that it can handle an argument that has an alias:

alias nohup='nohup '

Display all aliases:

alias

Display the alias for ls:

alias ls

Remove the aliases for nohup and du:

unalias nohup du

Remove all aliases for the current shell:

unalias -a

Remove all aliases for the current shell, assuming that an alias exists for unalias:

\unalias -a

Limitations

The versions of alias and unalias described here are available as built-in commands in ksh(C).

There is no aliasing mechanism available in sh(C).

The alias and unalias commands built into csh(C) differ from those described here.

Files


$HOME/.sh_history
default pathname of a user's command history file

See also

csh(C), ksh(C)

Standards conformance

alias and unalias are conformant with:

ISO/IEC DIS 9945-2:1992, Information technology - Portable Operating System Interface (POSIX) - Part 2: Shell and Utilities (IEEE Std 1003.2-1992);
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003