print friendly version

Questions and answers

227
How can I create shorthand versions of long or complex commands on the Unix system?


The commands described below need to be entered while logged in to the Unix server.   Normally you'll see a prompt ending with $ when the command interpreter (or shell) is ready for another command.

Use the alias command.

For example, if you put the following line in your .bashrc file:

alias lt='ls -lt|head'

then next time you log in, the command

lt

will list the 10 most recently changed files:  The command   ls -lt    lists files in long format;   the | symbol causes the output from ls -lt to be piped into the head command, which itself shows (by default) the first 10 lines of the data received.

Help us to improve this answer

Please suggest an improvement
(login needed, link opens in new window)

Your views are welcome and will help other readers of this page.

Categories

This is question number 227, which appears in the following categories:

Created by Andy Clews on 27 July 2001 and last updated by Andy Clews on 4 August 2015