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

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

?

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

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"

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

status measured difficulty not learned 37% [default] 0

No repetitions