On 23/08/2012 17:09, gene golub wrote:
Hello forum

I was wondering if somebody could explain what is the difference in use of the 
above within 'if' statement.
Is one superseds the other so I can use just one without ever considering the 
other.

Sample:
If [ -d somedir ];then
...

Hello Gene,

Double brackets implicitly quote all arguments, so you don't need to add quotes 
yourself.

If a="fee fie foe fum", then the expression [[ -f $a ]]
would be equivalent to [ -f "$a" ].

(The single '[' is effectively an alias for the builtin 'test', and ignores any 
trailing ']' character).


There is at least special case where quoting still makes
a difference inside double brackets: pattern matching.

[[ $a == fee* ]]  would test true for all strings $a starting with "fee".

[[ $a == "fee*" ]] would expect $a to contain the literal four character string 
"fee*"

Regards,
Henk
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to