[CentOS] C5 BASH IF

Sat Feb 14 05:46:42 UTC 2015
Les Mikesell <lesmikesell at gmail.com>

On Fri, Feb 13, 2015 at 11:26 PM, Always Learning <centos at u64.u22.net> wrote:
> Being new to some aspects of BASH, I tried to reduce the quantity of
> scripts by introducing a comparison test into an existing working
> script.
>
> The script refused to work until I placed [ ] around the actual test.
> The second test, in the same script, misfunctioned until I removed the
> [ ] around the second test.
>

I think you are missing some very basic concepts here.  First, the
shell likes to parse things separated by white space.  Second, [ is a
synonym for test which is a build-in version of /bin/test, so try 'man
test' for the syntax of tests.   And third, you generally should use
double quotes around variables in tests so they continue to exist as
an empty string if the variable happens to not be set.

-- 
   Les Mikesell
      lesmikesell at gmail.com