[CentOS] C5 BASH IF

Sat Feb 14 16:57:21 UTC 2015
Robert Nichols <rnicholsNOSPAM at comcast.net>

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.