&& and ; operators (Was Re: [GLLUG] grep help)
Edward Glowacki
glowack2 at gmail.com
Wed May 11 16:34:24 EDT 2005
Isn't it when you use the && (not ';') that the second one runs only
if the first doesn't return an error? Like "cd /etc && cat passwd"
will only try to display the password file if it could successfully
change to /etc.
-ED
On 5/11/05, Staff Staff <Staff at meridian.mi.us> wrote:
> 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
>
> _______________________________________________
> linux-user mailing list
> linux-user at egr.msu.edu
> http://www.egr.msu.edu/mailman/listinfo/linux-user
>
More information about the linux-user
mailing list