[CentOS] How to test for '.' in a script

James B. Byrne

byrnejb at harte-lyne.ca
Thu Jul 28 18:30:48 UTC 2011


I am trying to check for a single period '.' in a shell variable.

$ I=.
$ echo $I
.
$ if [[ "$I" -eq '.' ]]; then echo true; fi
-bash: [[: .: syntax error: operand expected (error token is ".")

All other variants of this construct, with and without escape
characters, single and double quote combinations, that I can think
of all give exactly the same error.

How does one check to see for this in a bash script?


-- 
***          E-Mail is NOT a SECURE channel          ***
James B. Byrne                mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3




More information about the CentOS mailing list