Use a command directly as the condition.
Section: Tests and Conditionals
Test command success
bash
bash
if grep -q needle file.txt; then echo found; fiExplanation
Shell conditions commonly use exit status rather than booleans.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Tests and Conditionals