The difference between parenthesis and brackets
The differences between [ ] [[ ]] and ( ) have been confusing to me.
() is for function headers Corrected parentheses - thanks chrism01 (( )) as I understand it is posix and is looking for numbers # abc=6 ; if (( $abc -eq 6 )) ; then ; blah [ ] is looking for a single logical condition # def="6" ; if [ "$def" == "6" ] ; then ; blah [[ ]] is newer, and works in bash and will take nested logical analysis. # abc=6 ; if [[ $( $abc -eq 6 ) ]] ; then ; blah I'm still not sure, but what I have been trying seems to have been working. It would really be cool if someone made up a good one pager with examples. |
@sarexpert:
http://www.tldp.org/LDP/abs/html/comparison-ops.html http://www.tldp.org/LDP/abs/html/ops.html Note that single () is for fn headers, double (( )) is for arithmetical comparisons. [[ ]] is preferred to [] because its more robust/better behaved - see those docs. |
All times are GMT -5. The time now is 01:43 PM. |