From owner-freebsd-questions Fri Jan 26 0:35: 2 2001 Delivered-To: freebsd-questions@freebsd.org Received: from shasta.wstein.com (rfx-64-6-196-149.users.reflexcom.com [64.6.196.149]) by hub.freebsd.org (Postfix) with ESMTP id 213A137B400 for ; Fri, 26 Jan 2001 00:34:44 -0800 (PST) Received: from hood (hood.wstein.com [192.168.250.14]) by shasta.wstein.com (8.11.1/8.11.1) with ESMTP id f0Q8Yh868097 for ; Fri, 26 Jan 2001 00:34:43 -0800 (PST) (envelope-from joes@joescanner.com) Date: Fri, 26 Jan 2001 00:34:43 -0800 (Pacific Standard Time) From: Joseph Stein To: Subject: Formatting a number Message-ID: X-X-Sender: joes@joescanner.com MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I am beating my head up trying to figure out how to do this; I've tried (what little I know) Perl, sed, awk, etc, and am stumped. This is my last-ditch resort... I have a script that checks the size of a staging directory (for offloading data to CD-R). It does a rudimentary check with something like this: DIRSIZE=`du -k /var/backup | tail -1 | awk '{ print $1 }'` That works just fine, and gives me the number of kilobytes used by my staging directory. However, because I am a want to see real numbers, I also pass it through a short perl script as well, for the report that gets mailed to me: perl -e "printf('is %10d bytes (%dK, %dM). (%5.2f%%)',\ ${DIRSIZE}*1024, ${DIRSIZE}, ${DIRSIZE}/1024, ((${DIRSIZE}/716800)*100));"\ >>/tmp/tempfile.$$.1 This outputs something like... is 470768640 bytes (459735K, 448M). (65.68%) But, I want that first really big number (ok, the second one too) to be formatted a la 470,768,640 bytes (459,735K; 448M). (65.68%) Any ideas? I know this is possible (but I haven't done it since my "Intro to Unix course years ago, and forgot how). Thanks in advance for any help, joe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message