Displaying 3 results from an estimated 3 matches for "law45p07a01".
2015 Feb 14
4
C5 BASH IF
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.
----------------------------
NON WORKING first comparison
5 if $dir="law"
2015 Feb 14
0
C5 BASH IF
...to match including items with no 'css' in the file
> name.
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
--
Regards,
Paul.
England, EU. Je suis Charlie.
2015 Feb 14
4
C5 BASH IF
...ks for that. I assumed if test 1 worked, so would test 2.
Have re-run test 2 with
> 16 if [ $file = "law00css" ]
> 17 then
> 18 echo $file
> 19 echo "css"
> 20 else
> 21 echo "no css"
> 22 fi
and got
> + '[' law45p07a01 = law00css ']'
> + echo 'no css'
> no css
> + exit
which is correct (for the first time). It seems that following your
good advice and plonking spaces around the = has solved the problem.
Thank you very much. Now I can go to bed a satisfied person :-)
--
Regards,
Paul....