When are square brackets required in a Bash if statement?
-
30-10-2019 - |
Question
Usually, I use square brackets in the if statement:
if [ "$name" = 'Bob' ]; then ...
But, when I check if grep
succeeded I don't use the square brackets:
if grep -q "$text" $file ; then ...
When are the square brackets necessary in the if
statement?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow