Exit Status and Chaining
Every command returns 0 for success or non zero for failure. && runs the next command only on success, || only on failure and ; always. exit sets the script status.
Example
true && echo "ran"
false || echo "fallback"
mkdir -p t && cd t && echo "in $(basename "$PWD")"
false; echo "continues"
(exit 3); echo "code $?"Result
ran fallback in t continues code 3
Exercise
Run only if the first worked.
cmd1 cmd2
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.