command || echo 'command failed'

Category: Bash Scripting

command || echo 'command failed'

Short-circuit OR: run second command only if first fails

Short-circuit OR: run the second command only if the first fails. Like 'try A, if it fails then do B'.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.