I have the following line in a shell script:
if [ -f /etc/init.d/tomcat6 && ps -C java|grep -qs 'java' ]; then
which throws up the following error when I try to run it:
line 12: [: missing `]'
I have a feeling that this is an encoding issue as I’ve been editing the file in Notepadd++ on a windows xp pc, I’ve ensured I’ve set the encoding to encode in UTF-8 without BOM and that all the line endings are linux style yet I still receive this error.
Can anyone help?
Thanks
Try
[is basically an alias for thetestcommand.testdoes not know anything about an argumentps. Alternatively you may usetestexplicitely (just to clarify syntax):If you use
[instead oftest, you are forced to end the expression with].