Date: Fri, 26 Jan 2001 00:34:43 -0800 (Pacific Standard Time) From: Joseph Stein <joes@joescanner.com> To: <questions@freebsd.org> Subject: Formatting a number Message-ID: <Pine.WNT.4.31.0101260023520.728-100000@hood>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.WNT.4.31.0101260023520.728-100000>