Bash shell scripting ( [[ ]] conditions)
A question was asked recently what is the difference between "[ ]" and "[[ ]]" when used in a conditional statement in bash shell scripting.
As I found making use of the [ ] provides what is known as a "simple" test.
if [ "one" = "one" ]; then
echo "one is one"
fi
Where as the [[ ]] provides for a compound test in addition to having conditional operators that are more typical in other languages.
if [[ "one" == "one" && "two" == "two" ]]; then
echo "Normality restored"
fi
Operators like && || and the like are not possible in the simple test
0 Comments:
Post a Comment
<< Home