Skip to main content
added 57 characters in body
Source Link

This is confusing me.

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" #

true return 0 exit code and false returns 1. I am unable to understand how || and && are working. Do both of them work on exit codes or the actual output of the command? What is the difference between && and || operator here?

The above code snippet is from the missing semester of your CS education lecture 2.

This is confusing me.

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" #

true return 0 exit code and false returns 1. I am unable to understand how || and && are working. Do both of them work on exit codes or the actual output of the command?

The above code snippet is from the missing semester of your CS education lecture 2.

This is confusing me.

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" #

true return 0 exit code and false returns 1. I am unable to understand how || and && are working. Do both of them work on exit codes or the actual output of the command? What is the difference between && and || operator here?

The above code snippet is from the missing semester of your CS education lecture 2.

Source Link

Difference between && and || operator in Bash

This is confusing me.

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" #

true return 0 exit code and false returns 1. I am unable to understand how || and && are working. Do both of them work on exit codes or the actual output of the command?

The above code snippet is from the missing semester of your CS education lecture 2.