Greater Than | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Greater Than

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-29-2003
Lem2003 Lem2003 is offline
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
Java 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!
Sponsored Links
    #2  
Old 08-29-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
 
Join Date: Aug 2002
Last Activity: 3 October 2004, 6:07 PM EDT
Location: Cleveland, OH
Posts: 804
Thanks: 0
Thanked 5 Times in 4 Posts
Try this:
Code:
#!/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:
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.

Sponsored Links
    #3  
Old 08-29-2003
Lem2003 Lem2003 is offline
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
Thanks, I was just seeing an example in a book. Is this the only way to do it? Thanks!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
greater than a certain value kvok Shell Programming and Scripting 4 01-27-2012 02:31 AM
find greater than value tmalik79 Shell Programming and Scripting 9 10-12-2011 03:42 PM
AWK greater than? dlam Shell Programming and Scripting 6 03-10-2008 03:43 AM
greater than less than in case sars Shell Programming and Scripting 2 02-18-2007 12:37 PM
AWK greater than 200 insania Shell Programming and Scripting 2 02-05-2007 03:03 PM



All times are GMT -4. The time now is 08:08 PM.