You are not logged in.
Pages: 1
Hi,
I'm writing a bash script and I am trying to test 2 strings in the same if statement, and it doesnt read the second statement,
if [ "$1" != "dbstart" -o "$1" != "dbstop" ]
then
echo 'use dbstart or dbstop'
else
su - postgres -c "sh ${1}.sh"
fi
I have also tried || with no success. The only way to make this work is to use a separate elif statement for each string.
So, is the "or" impossible or did I miss something really stupid?? thanks
Last edited by rickeyski (2011-05-16 19:05:08)
Offline
I think you want "and", not "or".
if [ "$1" != "dbstart" -a "$1" != "dbstop" ]
Offline
ahh thanks, dyslexic am i
Offline
I would not use [ ] tests though. If you are writing bash, use [[ ]] instead!
Offline
Pages: 1