Tsallaka zuwa abun ciki
Justice Tech School

&& and || Chaining

cmd1 && cmd2 runs the second only on success. cmd1 || cmd2 runs it only on failure.

Example
true && echo "ran"
false && echo "skipped"
false || echo "fallback"
mkdir -p /tmp/x_sh && echo "created"; rmdir /tmp/x_sh

Result

ran
fallback
created

Exercise

Run next only on success.

true  echo yes

Quiz Test

What does && do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.