Aliases

Aliases are command name macros used as shorthand for other commands, especially frequently used ones. This saves a lot of typing time. Aliases are defined with the alias name=value command. For example, we could create an alias for the print command like this:

					$ alias p=print
				

Whenever p is invoked, print is executed:

					$ p Hello
					Hello
				

Make sure to enclose the value in quotes if it contains whitespace. Here we create an alias l that is set to the ls –Fac command:

					$ alias l="ls —Fac"
				

Now when you type in l, ls –Fac is executed:

					$ l
					./
					../
					compress.Z*
					func.Z*
					test/
					uncompress.Z*
					. . .
				

Alias values can contain any text, including special characters, like wildcards, pipes, or I/O redirection operators. Let's change alias l so that ...

Get Korn Shell: Unix and Linux Programming Manual, Third Edition, The now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.