Use test -f app.conf to check whether the configuration file exists.
Run echo READY only when the check succeeds.
Which command list is correct?
In an AND list, && runs the right-hand command only when the previous command exits with status 0.
Detailed explanation
test -f app.conf && echo READYCorrect. echo runs only when test reports success.
Correct. echo runs only when test reports success.
test -f app.conf || echo READYIncorrect. || runs its right-hand side when the test fails.
Incorrect. || runs its right-hand side when the test fails.
test -f app.conf; echo READYIncorrect. ; runs echo regardless of the test result.
Incorrect. ; runs echo regardless of the test result.
test -f app.conf & echo READYIncorrect. & starts commands asynchronously and does not express a success condition.
Incorrect. & starts commands asynchronously and does not express a success condition.
Try it yourself
An example you can run in a temporary verification environment.
LAB_FILE=$(mktemp)
test -f "$LAB_FILE" && echo READY
rm "$LAB_FILE"Expected result
READYKey points
- Short-circuit evaluation with &&
- Exit status 0
- Conditional execution
Notes
- Environment: Bash 5.2
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.