Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Greater Than

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 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 Unix and Linux 08-29-2003
oombera's Unix or Linux Image
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 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

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.

The Following User Says Thank You to oombera For This Useful Post:
babinlonston (11-25-2014)
Sponsored Links
    #3  
Old Unix and Linux 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 01:31 AM
find greater than value tmalik79 Shell Programming and Scripting 9 10-12-2011 02:42 PM
AWK greater than? dlam Shell Programming and Scripting 6 03-10-2008 02:43 AM
greater than less than in case sars Shell Programming and Scripting 2 02-18-2007 11:37 AM
AWK greater than 200 insania Shell Programming and Scripting 2 02-05-2007 02:03 PM



All times are GMT -4. The time now is 03:06 AM.