home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

Unix Power ToolsUnix Power ToolsSearch this book

29.4. Setting and Unsetting Bourne-Type Aliases

A lot of what we said about aliases in Section 29.2 applies to the Korn shell (ksh), zsh, and bash. This article, along with Section 29.5 and Section 29.6, have an overview of what's different.

One thing that's different from C shells is the syntax of the alias command, which is:

$ alias name=definition

That is, you need an equal sign (no spaces) between the name and the definition. A good guideline is to use single quotes (') around the definition unless you're doing something specialized and you understand how quoting (Section 27.12) works in aliases.

You can't put arguments inside an alias as the C shell's \! operator (Section 29.3) does. To do that, use a shell function (Section 29.11).

As in the C shells, unalias removes an alias. To remove all aliases, use unalias -a in ksh and bash or unhash -a in zsh. alias with no arguments lists aliases that are currently defined.

bash aliases are pretty basic; this section covers them. Korn shell and zsh aliases do more.

--JP and SC

Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.