Results 1 to 6 of 6
Hi All,
I am trying to executing the below code, but i am not getting proper result??? can any one help me.
if [ '(10>1)' -a '(2<1)' ]
then
echo ...
- 11-26-2008 #1Just Joined!
- Join Date
- Aug 2008
- Posts
- 49
test -a is not working??? Logical AND
Hi All,
I am trying to executing the below code, but i am not getting proper result??? can any one help me.
if [ '(10>1)' -a '(2<1)' ]
then
echo "Successful condition"
else
echo "Failure condition"
fi
Here i should get "Failure condition", but i am getting Successful condition". The -a option is for Logical AND.
- 11-26-2008 #2Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Code:if [ 'this is a string' -a 'and strings are true' ] then echo "I didn't bother reading the man page" fi
- 11-26-2008 #3Just Joined!
- Join Date
- Aug 2008
- Posts
- 49
Hi..
I have executed with other condition also, the problem is else part is not executing.
test exp1 -a exp2
According to option -a, both the exp should be true then only it should execute. but here even one exp is fails also, still it will execute if part. So what is the solution???
- 11-26-2008 #4Linux Newbie
- Join Date
- Jul 2008
- Posts
- 181
Your first example indicates that you do not understand what expressions are considered true by test. Maybe you should show us "exp1" and "exp2"?
- 11-26-2008 #5
dayananda.ms, it's obvious from the dialog so far that you've tried reading the man page.
How about this?
Code:if [ 10 -gt 1 -a 2 -lt 1 ] then echo success else echo failure fi
--
Bill
Old age and treachery will overcome youth and skill.
- 11-26-2008 #6Just Joined!
- Join Date
- Aug 2008
- Posts
- 49
Thank you bill...


Reply With Quote