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:korn shell and arithmetic

Re: OT:korn shell and arithmetic

From: Tim Gorman <tim_at_sagelogix.com>
Date: Tue, 22 Jun 2004 21:27:12 -0600
Message-ID: <BCFE54B0.17055%tim@sagelogix.com>


Sorry, my friend, but that doesn't work...

    $ if [ 1.2 > 1.0 ]; then

    > echo "yes"
    > else echo "no"
    > fi

    yes

    $ if [ 1.2 > 1.3 ]; then

    > echo "yes"
    > else echo "no"
    > fi

    yes

The following is rather annoying, but it seems to work...

    $ if [[ "`bc << __EOF__^J1.2 > 1.0^J__EOF__`" = "1" ]]

    > then
    > echo yes
    > else echo no
    > fi

    yes

    $ if [[ "`bc << __EOF__^J1.2 > 1.3^J__EOF__`" = "1" ]]

    > then
    > echo yes
    > else echo no
    > fi

    no

The "^J" sequences are obtained using CTRL-V then CTRL-J (a.k.a. newline characters).

Korn shell can be quite roundabout quite often...

-Tim

on 6/22/04 11:28 AM, Mladen Gogala at mladen_at_wangtrading.com wrote:

>
> On 06/22/2004 01:06:03 PM, ryan.gaffuri_at_comcast.net wrote:

>> I don't know any unix listservs... so I hope this is ok.
>> 
>> I am trying to do the following:
>> 
>> if [ 1.2 -gt 1.0 ]; then
>>    echo yes
>> else echo no
>> fi
>> 
>> It alwys comes out no? Anyway to get around this?

>
> Yogi> cat /tmp/ttt
> #!/bin/ksh
>
> if [ 1.2 > 1.0 ]; then
> echo "yes"
> else echo "no"
> fi
> Yogi> /tmp/ttt
> yes
> Yogi>
>
> Try reading the fine manual. Below is the best manual around.
>
> Learning the Korn Shell
> By Bill Rosenblatt and Arnold Robbins
>
>


Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
Received on Wed Jun 23 2004 - 00:09:29 CDT

Original text of this message

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