Examples of passing arguments given to a command alias

To pass a single argument to a command alias:

   alias print 'lpr \!^ -Pps5'
   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 preceded by a \ to prevent it being interpreted by the shell as a history command.


To pass each argument to a command alias:

   alias print 'lpr \!* -Pps5'
   print part1.ps glossary.ps figure.ps

The notation !* causes each argument given to the alias print to be inserted in the command at this point. The command that is carried out is:

   lpr part1.ps glossary.ps figure.ps -Pps5

Notice that the ! character is preceeded by a \ to prevent it being interpreted by the shell as a history command.


[Home] [Search] [Index] This site maintained by webmaster@deslab.mit.edu