[mdlug] Difference between ; and &&

Brian Brodsky brianbrodsky at ameritech.net
Wed May 9 09:31:08 EDT 2012


Sorry my description is is backwards. Let me start over. The && means if 
first command successful we need to run the second command to see if the 
expression will be true. If the fist command is not the expression is 
false. (0 in this case means true, any other value means false)

On 5/9/2012 9:08 AM, Brian Brodsky wrote:
> Actually commands return a result code of 0 (usually means false) if
> successful and some exception value if not. So if successful it will
> return 0 which means it has to run the second command to see if the and
> condition is met, any exception would be a value so the second command
> does not have to be run since the expression is true.
>
> On 5/9/2012 8:29 AM, James Hice wrote:
>> For ;  each command is executed
>> For&&   the second command is only executed if the first returns true
>> On May 9, 2012 8:12 AM, "Mat Enders"<mat.enders at gmail.com>   wrote:
>>
>>> Hello all,
>>>
>>> When stringing commands together at the command line I always use the
>>> semicolon ;  I however see&&   used frequently and was wondering what
>>> the difference was.
>>>
>>> For example what is the difference between these commands:
>>>
>>> apt-get update;apt-get dist-upgrade
>>> and
>>> apt-get update&&   apt-get dist-upgrade
>>>
>>> --
>>> Mathew E. Enders
>>>
>>> "Where once Samba and Apache sold Linux to the world they are now just
>>> part of the plumbing.  But that's OK, plumbers make good money."
>>> --Jeremy Allison
>>> _______________________________________________
>>> mdlug mailing list
>>> mdlug at mdlug.org
>>> http://mdlug.org/mailman/listinfo/mdlug
>>>
>> _______________________________________________
>> mdlug mailing list
>> mdlug at mdlug.org
>> http://mdlug.org/mailman/listinfo/mdlug
>>
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
>



More information about the mdlug mailing list