From owner-freebsd-questions Thu Jun 5 20:05:48 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id UAA22941 for questions-outgoing; Thu, 5 Jun 1997 20:05:48 -0700 (PDT) Received: from adam.adonai.net ([205.182.92.2]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id UAA22936 for ; Thu, 5 Jun 1997 20:05:46 -0700 (PDT) Received: from localhost (leec@localhost) by adam.adonai.net (8.8.5/8.7.3) with SMTP id WAA24449; Thu, 5 Jun 1997 22:07:15 -0500 (CDT) Date: Thu, 5 Jun 1997 22:07:15 -0500 (CDT) From: "Lee Crites (AEI)" To: Tim Moony cc: questions@FreeBSD.ORG Subject: Re: Size of all files In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Thu, 5 Jun 1997, Tim Moony wrote: =>Sorry if this question is stupid. The only stupid question is the one unasked... (imnsho) =>Which command can tell me the total size of all files in a directory tree? I'm not sure what you are looking for exactly, but I have a script and awk file which give me something like what you are asking for. ----- hmr script ----- #!/bin/csh -f # Get a listing (using ls -AlR) and pass it into hmr.awk ls -AlR $* | awk -f $0.awk ----- end of hmr script ----- hmr.awk script ----- # Add up the size of each file information passed in (in ls -l format) # and report the number of items and total size of all items combined. BEGIN { cnt = 0 tot = 0 } { link = $11 size = $5 if (link == "") { if (size != "") { cnt++ tot += $5 } } } END{ printf("%d items, %d bytes", cnt, tot) if (tot > (8 * 1024)) { printf(" (%.2fK)", (tot/1024)) } if (tot > (1024 * 1024)) { printf(" (%.2fM)", (tot/(1024*1024))) } printf("\n") } ----- end of hmr.awk script ----- Lee