![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unix Arithmatic operation issue , datatype issue | thambi | Shell Programming and Scripting | 23 | 02-19-2008 07:19 AM |
| Strange issue | AndrewSH | UNIX for Dummies Questions & Answers | 1 | 01-29-2008 05:33 PM |
| root Password ... strange issue | badrali | Security | 6 | 06-28-2007 09:41 AM |
| random number logic -- issue | asutoshch | High Level Programming | 1 | 05-09-2003 11:07 AM |
| comparison | cnf | Filesystems, Disks and Memory | 2 | 05-14-2002 01:52 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Strange Number comparison issue
Hi,
I am comparing two numbers, but it gives strange results: My Code: if [ ${STARTTIME} -gt ${DATE_TIME} ] then echo "True" else echo "False" fi This code gives False for the follwoing comparison [ 20040109195224 -gt 20070409200951 ] where as True for the following: [ 20050109195224 -gt 20070409201317 ] Any reason for this? Both Should have given False... I am using ksh shell on HP UX Please help me Shihab |
|
||||
|
Quote:
As pointed, it would work, here is a sample that I tried in zsh Code:
if [ 20040109195224 -lt 20070409200951 ] then echo "yes" else echo "no" fi yes ![]() |
|
||||
|
See My code :
#!/bin/ksh STARTTIME=20050109195224 DATE_TIME=20070409201317 if (( STARTTIME > DATE_TIME )) ; then echo "No" else echo "Yes" fi STARTTIME=20060109195224 DATE_TIME=20070409201317 if (( STARTTIME > DATE_TIME )) ; then echo "No" else echo "Yes" fi Gives No for first if and Yes for the second one As I mentioned using KSH on HP-UX |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|