I see people writing their bash scripts with conditional statements in different formats. For example here are a few instances:
x=20;
if [ "$x" -eq "20" ];
then
echo "1. yes!";
fi
if [[ "$x" -eq "20" ]];
then
echo "2. yes!";
fi
if (( "$x" == "20" ));
then
echo "3. yes!";
fi
The above code gives me all three as YES, in a bash shell.
Clearly, I see various differences in using each of these syntaxes for example when I need compound-logical-statements (using things such as && ||) OR string/numerical comparisons.
Adding to this confusion, even variable access seems to have this difference $x $((x)) ${x} etc.
Can somebody please clarify how each of above syntaxes important and demystify my thoughts?