start page | rating of books | rating of authors | reviews | copyrights

Unix Power ToolsUnix Power ToolsSearch this book

29.5. Korn-Shell Aliases

pdksh (the public domain ksh) has three types of aliases. First is the regular command alias covered in Section 29.4.

Tracked aliases keep track of the locations of external (Section 1.9) executables. The shell has a default list of commands to track (see the ksh manpage). The first time ksh searches the PATH for an executable command that's marked as a tracked alias, it saves the full path of that command. This saves the shell the trouble of performing the path search each time a command is invoked. The tracked aliases aren't reset unless one becomes invalid or you change the PATH. The command alias -t lists and creates tracked aliases. Here's an example with a newly invoked Korn shell:

$ alias -t
$ cat somefile > somewhere
$ alias -t
cat=/bin/cat
$ alias -t less
$ alias -t
cat=/bin/cat
less=/usr/bin/less

At first, there are no tracked aliases. But the cat command is marked for tracking; as soon as I use it, the shell saves its location, as the next alias -t shows. Next, I add a tracked alias for less (Section 12.3) (which isn't one of the default commands to track). The Korn shell won't track a command unless it's one of the defaults or you mark it for tracking.

The third kind of alias, directory aliases, set with alias -d, let you use a tilde abbreviation like ~dir for any directory.

-- JP



Library Navigation Links

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