Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://comet.sai.msu.ru/UNIXhelp/shell/alias_csh5.html
Дата изменения: Fri Jan 17 12:43:20 1997 Дата индексирования: Tue Oct 2 01:28:37 2012 Кодировка: Поисковые слова: п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п |
To create a simple command alias:
alias del 'rm -i' del memo.txt rm: remove memo.txt? y
This creates the alias del for the command rm -i which prompts you for confirmation that you want to remove a file before it does so.
You can make this alias a permanent feature of your environment by adding it to your shell start up file .cshrc.
To create a command alias that consists of several commands:
alias what 'ps -aux | grep $USER | less'
This creates the alias what.
Entering the command what will now run the command
ps -aux | grep $USER | less
which consists of three commands linked together with pipes.
To refer to another command alias within an alias:
alias h history alias rev 'h | tail -10'
The first command assigns the alias h to the history command. The next command assigns the alias rev to the command h | tail -10. This takes the output from the alias h ( the history command) and pipes it through the tail command to list the ten most recent commands in the command history.
To pass command arguments to the alias:
alias print 'lpr \\!^ -Pps5'
To print a file to the printer ps5 the user enters a command such as:
print memo.txt
The notation !^ causes the first argument to the command alias print to be inserted in the command at this point. The command that is carried out is:
lpr memo.txt -Pps5
Notice that the ! character is preceeded by a \\ to prevent it being interpreted by the shell as a history command.