Use a shell test in an if statement.
Section: Conditionals Loops and Functions
Check whether file exists
bash
bash
if [[ -f /etc/app.conf ]]; then echo 'exists'; fiExplanation
Common script pattern for optional config files.
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 Conditionals Loops and Functions