Aliases

Another shell technique that can save you a few keystrokes is using an alias. An alias is a way of doing something in shorthand. An alias is defined using a name/value pair. For example, the following alias takes the command ls -la and assigns it to the alias ll:

alias ll='ls -la'

After this alias has been created (either in a script, such as .profile, or manually at a shell prompt), the user can type ll and get a long listing:

 $ ll total 56 drwx------ 6 shell shell 4096 May 16 10:32 . drwxr-xr-x 22 root root 4096 Mar 27 14:26 .. -rw-r--r-- 1 shell shell 1422 Mar 27 14:26 .Xdefaults -rw-r--r-- 1 shell shell 24 Mar 27 14:26 .bash_logout -rw-r--r-- 1 shell shell 230 Mar 27 14:26 .bash_profile -rw-r--r-- 1 shell shell 173 Mar 27 14:26 ...

Get Korn Shell Programming by Example 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.