As far as I understand,
= expects string
-eq expects integers
"$ bar" for letter matches, i.e. z * can expand, but "z *" will literally match the char pattern.
The difference between [] and [[]] is that in the last word splitting and extension of the path name are not performed, but are in the first.
Plus [[]] allows you to use additional operators:
& & (ALSO), || (OR),> (String1 is lexically larger than String2), <(String1 is lexically smaller than String2)
The comparison operator == works differently in a test with two brackets than in separate brackets.
[[$ a == z *]] # True if $ a starts with "z" (pattern matching).
[[$ a == "z *"]] # True if $ a is equal to z * (literal match).
[$ a == z *] # Performs file splitting and word splitting.
["$ a" == "z *"] # True if $ a is equal to z * (literal match).
For more information contact http://tldp.org/LDP/abs/html/comparison-ops.html
lucas1000001
source share