The alias built-in defines and/or prints aliases.

Syntax

  • alias [-gp] [name[=value]…]

Description

The alias built-in defines and/or prints aliases as specified by operands. The printed aliases can be used as (part of) shell commands. The built-in prints all currently defined aliases when given no operands.

Options

-g
--global

With this option, aliases are defined as global aliases; without this option, as normal aliases.

-p
--prefix

With this option, aliases are printed in a full command form like alias -g foo='bar'. Without this option, only command operands are printed like foo='bar'.

Operands

name

The name of an alias that should be printed.

name=value

The name and value of an alias that is being defined.

Exit status

The exit status of the alias built-in is zero unless there is any error.

Notes

The characters that cannot be used in an alias name are the space, tab, newline, and any of =$<>\'"`;&|()#. You can use any characters in an alias value.

The alias built-in is a mandatory built-in.

The POSIX standard defines no options for the alias built-in, thus no options are available in the POSIXly correct mode.