maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   General (https://talk.maemo.org/forumdisplay.php?f=7)
-   -   [Help/Solved] Conditional Operations for Shell Scripting (https://talk.maemo.org/showthread.php?t=65425)

bakuur 2010-11-10 21:33

[Help/Solved] Conditional Operations for Shell Scripting
 
okay guys i would really appreciate it if someone tells me how can i produce a command that goes as follow

Code:

echo $x

if [ 80 > $x > 20 ];then

Command

fi

ive tried this

Code:

if [ 80 -gt $x -gt 20 ]
and it failed to work

also tried


Code:

if [ $x -ge 20 ];
elif [ $x -le 80 ];then

same thing , didn't work


i would really appreciate some help as i know its simple to you but not me cause so far I've been stuck , as I'm working on this shell script and need to put the X between two values.

cheers,
bakuur

hqh 2010-11-10 21:46

Re: [Help] Conditional Operations for Shell Scripting
 
It should be
Code:

if [ $x -gt 20 ] && [ $x -lt 80 ]; then
    command
fi


blue_led 2010-11-10 21:49

Re: [Help] Conditional Operations for Shell Scripting
 
if [ $x -gt 20 -a $x -lt 80 ]

bakuur 2010-11-10 21:53

Re: [Help] Conditional Operations for Shell Scripting
 
Quote:

Originally Posted by blue_led (Post 869699)
if [ $x -gt 20 -a $x -lt 80 ]

you know im doing that for the LED-Batt indicator
finally got the chance to work on it

hope this works really

blue_led 2010-11-10 21:59

Re: [Help] Conditional Operations for Shell Scripting
 
baftă ( romanian )

bakuur 2010-11-10 22:01

Re: [Help] Conditional Operations for Shell Scripting
 
Quote:

Originally Posted by blue_led (Post 869709)
baftă ( romanian )

thanks a lot mate ;)


All times are GMT. The time now is 21:10.

vBulletin® Version 3.8.8