Re: How to test for '.' in a script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Thu, 28 Jul 2011, James B. Byrne wrote:

> I am trying to check for a single period '.' in a shell variable.
>
> $ I=.
> $ echo $I
> .
> $ if [[ "$I" -eq '.' ]]; then echo true; fi

   if [ "$I" = '.' ]; then ...

Use a single = rather than -eq (which tests numeric equality) and use
single brackets -- or, better, call test directly:

   if test "$I" = '.'; then ...

"help test" is your friend!

-- 
Paul Heinlein <> heinlein@xxxxxxxxxx <> http://www.madboa.com/
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux