From owner-freebsd-questions Thu Aug 22 23:28:32 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3362937B400 for ; Thu, 22 Aug 2002 23:28:29 -0700 (PDT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 99EB343E4A for ; Thu, 22 Aug 2002 23:28:28 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.5/8.12.5) id g7N6SQjK040724; Fri, 23 Aug 2002 01:28:26 -0500 (CDT) (envelope-from dan) Date: Fri, 23 Aug 2002 01:28:26 -0500 From: Dan Nelson To: "Christopher J. Umina" Cc: FreeBSD Question Mailing List Subject: Re: expr replacement Message-ID: <20020823062826.GF34104@dan.emsphone.com> References: <20020823021838.V67143-100000@216-164-225-145.c3-0.wth-ubr2.sbo-wth.ma.cable.rcn.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020823021838.V67143-100000@216-164-225-145.c3-0.wth-ubr2.sbo-wth.ma.cable.rcn.com> X-OS: FreeBSD 5.0-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG In the last episode (Aug 23), Christopher J. Umina said: > Hi guys & gals, > > 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` To return a number from 0..100: percentage=`expr $dirttl \* 100 / $totalsongs` If you want a fractional result you'll have to use the bc command, which is an arbitrary-precision calculator. -- Dan Nelson dnelson@allantgroup.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message