Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of "&&" in a shell command?

As far as I know, using & after the command is for running it in the background.

Example of & usage: tar -czf file.tar.gz dirname &

But how about &&? (example)

like image 930
Captain Avatar asked Dec 22 '10 15:12

Captain


People also ask

What is the purpose?

the reason for which something exists or is done, made, used, etc. an intended or desired result; end; aim; goal. determination; resoluteness. the subject in hand; the point at issue. practical result, effect, or advantage: to act to good purpose.

Is it the purpose for or the purpose of?

The "purpose of" a shoe is protecting your feet. A possible "purpose for" a shoe is to smash bugs. So "purpose of" describes a property or capacity of a shoe, where "purpose for" describes what might be done with a shoe. Save this answer.

What is purpose and example?

Purpose is defined as to plan or intend to do something. An example of purpose is someone deciding they will start saving 10% of their income. verb. 5. A result that is desired; an intention.

What is the real purpose of life?

Your life purpose is your contribution However, true purpose is about recognizing your own gifts and using them to contribute to the world—whether those gifts are playing beautiful music for others to enjoy, helping friends solve problems, or simply bringing more joy into the lives of those around you.


1 Answers

Furthermore, you also have || which is the logical or, and also ; which is just a separator which doesn't care what happend to the command before.

$ false || echo "Oops, fail" Oops, fail  $ true || echo "Will not be printed" $    $ true && echo "Things went well" Things went well  $ false && echo "Will not be printed" $  $ false ; echo "This will always run" This will always run 

Some details about this can be found here Lists of Commands in the Bash Manual.

like image 173
plundra Avatar answered Oct 17 '22 07:10

plundra