Home Search Forums Register Forum Rules Man Pages Unix Commands Linux Commands FAQ Members Search Today's Posts Mark Forums Read

 Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

# Greater Than

## Shell Programming and Scripting

#1
08-29-2003
 Lem2003 Registered User Join Date: May 2003 Last Activity: 3 March 2004, 4:00 PM EST Posts: 14 Thanks: 0 Thanked 0 Times in 0 Posts
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.

Code:
```#!/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!
#2
08-29-2003
 oombera   Registered User Join Date: Aug 2002 Last Activity: 3 October 2004, 6:07 PM EDT Location: Cleveland, OH Posts: 804 Thanks: 0 Thanked 6 Times in 5 Posts
Try this:
Code:
```#!/usr/bin/sh
_curTime=`date +%H%M`
if [ _curTime -lt 2400 ] && [ _curTime -gt 0800 ]
then
echo "\$_curTime"
fi```

Code:
```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.```

 The Following User Says Thank You to oombera For This Useful Post: babinlonston (11-25-2014)