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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.