From owner-freebsd-questions@FreeBSD.ORG Sun Aug 8 22:20:28 2004 Return-Path: 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 B44A116A4CF for ; Sun, 8 Aug 2004 22:20:28 +0000 (GMT) Received: from ybbsmtp04.mail.yahoo.co.jp (ybbsmtp04.mail.yahoo.co.jp [210.81.151.172]) by mx1.FreeBSD.org (Postfix) with SMTP id 9205343D41 for ; Sun, 8 Aug 2004 22:20:27 +0000 (GMT) (envelope-from ayakokiko@ybb.ne.jp) Received: from unknown (HELO gorgon.near.this) (219.11.234.11 with poptime) by ybbsmtp04.mail.yahoo.co.jp with SMTP; 8 Aug 2004 22:20:26 -0000 X-Apparently-From: Received: from hydra.near.this (hydra.near.this [10.0.3.20]) by gorgon.near.this (Postfix) with ESMTP id 424537F24; Mon, 9 Aug 2004 07:20:19 +0900 (JST) Received: by hydra.near.this (Postfix, from userid 100) id DB9599826; Mon, 9 Aug 2004 07:20:17 +0900 (JST) Date: Mon, 9 Aug 2004 07:20:17 +0900 From: horio shoichi To: "Hakim Z. Singhji" In-Reply-To: <4116489D.2010905@earthlink.net> References: <411318A8.4080100@earthlink.net> <20040806161222.O275@grond.sourballs.org> <4115842C.2090907@earthlink.net> <20040808072043.S10021@grond.sourballs.org> <4116489D.2010905@earthlink.net> X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-portbld-freebsd4.9) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-Id: <20040808.222017.0044ba5c0a5e67e2.10.0.3.20@bugsgrief.net> cc: questions@freebsd.org cc: David Fleck Subject: Re: Help Debugging Kshell Script??? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Aug 2004 22:20:28 -0000 On Sun, 08 Aug 2004 11:37:01 -0400 "Hakim Z. Singhji" wrote: > do > # Use the bc utility in a here document to calculate the percentage of > # free and used swap space > > PERCENT_USED=$(bc < scale=4 > ($SW_USED / $SW_TOTAL) * 100 > EOF > ) > > PERCENT_FREE=$(bc < scale=4 > ($SW_FREE / $SW_TOTAL) * 100 > EOF > ) > ########################################################################## Which ksh are you running (/usr/local/bin/ksh{,93)) ? If you are really new to this sort of things, test them interactively with 'set -ux' options. horio shoichi BTW., it gave me a thing like this on 4.9-STABLE with /usr/local/bin/ksh. % ksh $ SW_USED=1 $ SW_TOTAL=3 $ PERCENT_USED=$(bc < scale=4 > ($SW_USED / $SW_TOTAL) * 100 > EOF > ) $ echo $PERCENT_USED 33.3300 $ ^D %