Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Aug 2002 02:55:57 -0400 (EDT)
From:      "Christopher J. Umina" <uminac@216-164-225-145.c3-0.wth-ubr2.sbo-wth.ma.cable.rcn.com>
To:        Edwin Groothuis <edwin@mavetju.org>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: expr replacement
Message-ID:  <20020823025441.O44828-100000@216-164-225-145.c3-0.wth-ubr2.sbo-wth.ma.cable.rcn.com>
In-Reply-To: <20020823063308.GL785@k7.mavetju>

next in thread | previous in thread | raw e-mail | index | archive | help
When I do that it doesn't get the values for some reason and it gives me a
divide by zero error...  I think it's because Perl's looking for it's own
variables, not the ones set in the shell script.  But I can't think of a
way to put them in there.  The problem with expr is that I can't get to 2
decimal places.  I really need that.

On Fri, 23 Aug 2002, Edwin Groothuis wrote:

> On Fri, Aug 23, 2002 at 02:21:14AM -0400, Christopher J. Umina wrote:
> > 	I'm writing a simple shell script that finds percentages for me.
> > The problem here is that when I do the division with expr I always get a
> > result of 0 since it's below 1.  Is there a replacement for this or am I
> > just doing it wrong?  Take a look..  This is my command.
> >
> > percentage=`expr $dirttl / $totalsongs`
> >
> > where $totalsongs = aroudn 1000 and dirttl = anywhere from 8 to 565.
>
> Use a bulldozer: percentage=`perl -e "print $dirttl / $totalsongs"`
>
> Edwin
> --
> Edwin Groothuis      |            Personal website: http://www.MavEtJu.org
> edwin@mavetju.org    |    Weblog: http://www.mavetju.org/weblog/weblog.php
> bash$ :(){ :|:&};:   | Interested in MUDs? http://www.FatalDimensions.org/
>


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020823025441.O44828-100000>