[COLUG] Bash tests with [[ double square brackets ]].

Ken Bradford ken at alpha2.com
Thu Jun 24 10:12:52 EDT 2004


Could someone please explain why I need to use double square brackets in
these 2 tests?

if [[ "$proto" != \#* ]] && [[ $proto != "" ]]; then...

The first checks for comment lines, the second for blank lines. If I use
single square brackets then the first doesn't treat the "*" as a wildcard
and the second returns:

"[: !=: unary operator expected"

If it encounters a blank line.
I came across the "[[ ]]" syntax on the web, but without explanation.

Ken Bradford
Alpha II Service, Inc.




More information about the colug mailing list