&& and ; operators (Was Re: [GLLUG] grep help)

Staff Staff Staff at meridian.mi.us
Wed May 11 16:16:39 EDT 2005


Mike says he's got it, but I'll post this for the group, since I think
this might be the easiest and quickest solution:

The '&&' and ';' parameters allow you to specify multiple commands on a
single command line.  In the example provided by Mike, he wants to run a
head and a tail on the same file at the same time.  The above mentioned
tools allow us to use the combination of head and tail commands already
specified by others:
head -1 <filename> && tail -3 <filename>
or 
head -1 <filename> ; tail -3 <filename>

The difference between the && and the ; is that when you use the ';'
the second command will only run if the first command does not return an
error.
 
Good luck, and have fun playing!

-stephen

Stephen Gebes
Meridian Township



More information about the linux-user mailing list