Re: C5 BASH IF

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



On 02/13/2015 11:47 PM, Always Learning wrote:
I re-ran the script with 'set -x' for

16 if  [ $file='law00css' ]
17   then
18        echo $file
19        echo "css"
20 else
21        echo "no css"
22 fi

and received:-

+ '[' law45p07a01=law00css ']'
+ echo law45p07a01
law45p07a01
+ echo css
css

Correct. You invoked the test command with a single argument, the
string "law45p07a01=law00css". With a single argument, the test is
just whether that argument in non-null, which it is. To perform
a comparison you need 3 separate arguments (2 operands and an
operator), not 1.

--
Bob Nichols     "NOSPAM" is really part of my email address.
                Do NOT delete it.

_______________________________________________
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