need correction for shell script
even i enter 3 number this message is always displayed "Enter 3 number please"
here is the code echo enter 3 numbers read n1 n2 n3 if test "$n1" -o -z "$n2" -o -z "$n3" then echo "Enter 3 number please" elif [ $n1 -ge $n2 -a $n1 -a $n3 ] then echo $n1 is maximum number elif [ $n2 -ge $n1 -a $n2 -a $n3 ] then echo $n2 is maximum number elif [ $n3 -ge $n1 -a $n3 -a $n2 ] then echo $n2 is maximum number fi |
Hi,
This: if test "$n1" -o -z "$n2" -o -z "$n3" Should be: if test -z "$n1" -o -z "$n2" -o -z "$n3" But there are some other 'strange' things: $n1 -ge $n2 -a $n1 -a $n3 => Why the double -a check? Are you really checking if the could be files(-a file = True if file exists)? I need to start assuming to give further advise, I'll just wait if you need any further advise. Hope this helps. |
Quote:
3333 5 2563584 the ,maximum number is 5 how can? |
Hi,
Yep found that out myself too. The logic is not correct. Here's a working version: Code:
#!/bin/bash |
I got the logic,,,, thanksss
|
All times are GMT -5. The time now is 12:58 PM. |