Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: OT: shell script to compare nos.

Re: OT: shell script to compare nos.

From: Alex Apostolopoulos <a.apostolopoulos_at_TRUCK24.com>
Date: Wed, 11 Apr 2001 02:02:49 -0700
Message-ID: <F001.002E6D18.20010411010112@fatcity.com>

Hi
I'm sure there are better ways but awk does the trick

echo $var1 $var2 | awk '{ if ( $1 > $2 ) { print "1"} else { print"0" } }'

cheers alex

> Hello,
>
> I need some help in comparing 2 nos. in a unix shell.
>
> 1) e.g var1="7.04.03"
> and var2="7.05"
>
> I want to test:-
>
> if [ "$var2" > "$var1" ];then
> then $var2 version is greater than $var1"
> fi
>
> 2) 2nd condition is :-
>
> var1="7.04.03"
> var2="7.04.02"
>
> I want to test:-
> if [ "$var1" > "$var2" ];then
> then $var1 version is greater than $var2"
> fi
>
> Can some one send me a code?
>
> How can I do the above in shell? Can you please help me, a seemingly simple
> one!
>
>
> Raja
>
>
>
> Get 250 color business cards for FREE! at Lycos Mail
> http://mail.lycos.com/freemail/vistaprint_index.html

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Alex Apostolopoulos
  INET: a.apostolopoulos_at_TRUCK24.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Apr 11 2001 - 04:02:49 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US