Beginner
Linux & Shell Scripting
Q27 / 100
What does an "if" statement check in a bash script, and how is its condition typically written?
Correct! Well done.
Incorrect.
The correct answer is A) Conditions are written using square brackets, e.g. "if [ $x -gt 5 ]; then ... fi", testing whether the enclosed expression evaluates to true
A
Correct Answer
Conditions are written using square brackets, e.g. "if [ $x -gt 5 ]; then ... fi", testing whether the enclosed expression evaluates to true
Explanation
In bash, "[ ]" (or "[[ ]]" for extended tests) evaluates the enclosed expression; combined with "if ... then ... fi", it controls conditional execution based on the result.
Progress
27/100