Greater Than

Hello every one! I need a little help. I would like to know if there is someway I can use a "greater than" condition in a shell script.

#!/usr/bin/sh
_curTime=`date +%H%M`
if [_curTime<2400] && [_curTime>0800]
then
        echo "$_curTime"
fi

I know that "<" and ">" is to input and output to a file I just wanted to ilustrate my example.

Thank you all!

Try this:

#!/usr/bin/sh
_curTime=`date +%H%M`
if [ _curTime -lt 2400 ] && [ _curTime -gt 0800 ]
then
        echo "$_curTime"
fi

See the man page for test for more info:

n1 -eq n2   True if the integers n1 and n2 are algebraically equal.
n1 -ne n2   True if the integers n1 and n2 are not algebraically equal.
n1 -gt n2   True if the integer n1 is algebraically greater than the integer n2.
n1 -ge n2   True if the integer n1 is algebraically greater than or equal to the integer n2.
n1 -lt n2   True if the integer n1 is algebraically less than the integer n2.
n1 -le n2   True if the integer n1 is algebraically less than or equal to the integer n2.
s1          True if s1 is not the null string.
s1 = s2     True if strings s1 and s2 are identical.
s1 != s2    True if strings s1 and s2 are not identical.
1 Like

Thanks, I was just seeing an example in a book. Is this the only way to do it? Thanks!