Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Question

In linux, when running two or more commands together, what is the difference between && vs ||, i.e. the following two line:

command1 && command2
command1 || command2

Answer
When using &&, it means run command2 only if command1 returns with success exit code (i.e. 0)
When using ||, it means run command2 only if command1 returns error exit code (i.e. non 0)

Question

In linux, when running two or more commands together, what is the difference between && vs ||, i.e. the following two line:

command1 && command2
command1 || command2

Answer
?

Question

In linux, when running two or more commands together, what is the difference between && vs ||, i.e. the following two line:

command1 && command2
command1 || command2

Answer
When using &&, it means run command2 only if command1 returns with success exit code (i.e. 0)
When using ||, it means run command2 only if command1 returns error exit code (i.e. non 0)
If you want to change selection, open document below and click on "Move attachment"

20. Advanced Shell Scripting
sh shell scripting begun in Chapter 7 and expanded on in Chapter 9. These three chapters represent almost everything you can do with the bash shell. 20.1 Lists of Commands The special operator <span>&& and || can be used to execute functions in sequence. For instance: grep '^harry:' /etc/passwd || useradd harry The || means to only execute the second command if the first command returns an e

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.