Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Jan 2000 14:39:49 +0100 (CET)
From:      Oliver Fromme <olli@dorifer.heim3.tu-clausthal.de>
To:        freebsd-questions@FreeBSD.ORG, dl@tyfon.net
Subject:   Re: mathematics in sh
Message-ID:  <200001111339.OAA30067@dorifer.heim3.tu-clausthal.de>
In-Reply-To: <85eqqp$1sfn$1@atlantis.rz.tu-clausthal.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Dan Larsson <dl@tyfon.net> wrote in list.freebsd-questions:
 > Is it possible to do mathematical ( simple calculations such as ($a + $b)/$c ) calculations in sh?

I usually use ``expr'' for integer calculations, and ``dc'' for
floating point stuff.  I try to avoid the shell's arithmetic
expansion, because it's not portable to all sh implementations.
For more complicated stuff, I use awk.  Or C, if appropriate.

See ``man expr'', ``man dc'' and (if you don't like the RPN of
dc) ``man bc''.

 > Or is perl better to use in this case?

I think perl is never better to use.  :-)

Regards
   Oliver

-- 
Oliver Fromme, Leibnizstr. 18/61, 38678 Clausthal, Germany
(Info: finger userinfo:olli@dorifer.heim3.tu-clausthal.de)

"In jedem Stück Kohle wartet ein Diamant auf seine Geburt"
                                         (Terry Pratchett)


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?200001111339.OAA30067>