Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 May 1998 17:29:21 +0200 (CEST)
From:      Leif Neland <leifn@internet.dk>
To:        Jon Hamilton <hamilton@pobox.com>
Cc:        Child <child@mctcnet.net>, questions@FreeBSD.ORG
Subject:   Re: sh/csh sums? 
Message-ID:  <Pine.BSF.3.96.980516172515.2870A-100000@darla.swimsuit.internet.dk>
In-Reply-To: <199805161336.GAA15216@hub.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 16 May 1998, Jon Hamilton wrote:

> 
> In message <Pine.BSF.3.96.980516002949.4486A-100000@sommer.dyn.ml.org>, Child w
> rites:
> } HI all
> } 
> } I am looking for a way to get sh/csh to do simple sums
> } ie 145553/1024 
> } 
> } thanks
> } JS
> 
> To pick a nit, that's not a sum, but to answer your question as it applies to
> sh:
> 
> $ echo $((145553/1024))
> 142
> 


Or:

 $ expr 145553 / 1024

You need spaces around the operators. * must be escaped \* just as \( and
\)


 
> Most older versions of sh will either not have this feature, or it'll be
> limited to addition and subtraction.  Newer (POSIX-ized) versions generally
> do OK in this regard.  

expr is ok in old stuff too...


Leif Neland
leifn@internet.dk



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?Pine.BSF.3.96.980516172515.2870A-100000>