Example of using the && operator

To notify the user about the outcome of a previous command:

   cat deliver
   # usage: deliver username  filename
   { cat $2 | write $1 ; } && echo done

The user types a command such as:

   deliver keith greeting

The first command { cat $2 | write $1 ; } concatenates and displays the message held in the file greeting and pipes the output through the write command whose argument is the name of the user to whom the message is to be sent.

Note the use of the positional parameters $1 and $2. The ; (semicolon) is needed to sequentially execute the preceeding pipeline.

If this command is successful, the message done is displayed on standard output.

[Home] [Search] [Index]