During script execution, an administrator needs to ensure a command is executed only when a certain variable holds the exact word 'config'. Which syntax will correctly verify this within an if statement?
The conditional test using == is the correct answer because in shell scripting, this operator is used to compare two strings for equality. The single [ and double [[ are both used for the test construct, but the double bracket [[ is a newer Bash construct that offers additional functionality, such as regex matching and doesn't require quotes around the variable. The other answers are incorrect because -eq is used for arithmetic comparison, and using != would check for inequality, which is not the desired operation.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the difference between single and double brackets in Bash scripting?
Open an interactive chat with Bash
What does the `==` operator do in the context of Bash scripting?
Open an interactive chat with Bash
Why is `-eq` an incorrect choice for comparing strings in Bash?