From owner-freebsd-stable@FreeBSD.ORG Wed Oct 8 06:43:54 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0BC61106568D for ; Wed, 8 Oct 2008 06:43:54 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [220.233.188.227]) by mx1.freebsd.org (Postfix) with ESMTP id 7C6808FC20 for ; Wed, 8 Oct 2008 06:43:53 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id m986hoQb099743; Wed, 8 Oct 2008 17:43:51 +1100 (EST) (envelope-from smithi@nimnet.asn.au) Date: Wed, 8 Oct 2008 17:43:50 +1100 (EST) From: Ian Smith To: lhmwzy In-Reply-To: <78fb9d960810072118k47a64097yaa486ef5179efb1@mail.gmail.com> Message-ID: <20081008165835.C16723@sola.nimnet.asn.au> References: <200810071314.45922.max@love2party.net> <48EB5ADD.2090900@modulus.org> <78fb9d960810072118k47a64097yaa486ef5179efb1@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-stable@freebsd.org, Andrew Snow Subject: Re: zfs quota question X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Oct 2008 06:43:54 -0000 On Wed, 8 Oct 2008, lhmwzy wrote: > The fllow is better? > #!/bin/sh > find $1 -type f -exec ls -lh {} \; | awk '{j += $5} END {print j"M"}' Review your 'ls -lh' output; what's 100Bananas + 10Kiwifruit + 1Melon? $ find . -type f -exec ls -lh {} \; | awk '{j += $5} END {print j"M"}' 1.15975e+06M Took several minutes to come up with the wrong answer :) $ /root/bin/dirsize . 6906276646 Took 2.75 seconds, giving actual total of the file sizes. $ du -d0 . 6781976 . Took 1.5 seconds, and comes to 69447434424, ie bytes allocated for those files. All on a 300MHz Celeron. > 2008/10/7 Andrew Snow : > >> I love ZFS, but I suddenly found out last night that I > >> have lost the ability tto do a 'du' on a directory to work out if it will > >> fit onto a CD or not :-) > > > > I have created a shell script, /usr/local/bin/dirsize : > > > > #!/bin/sh > > find $1 -type f -ls | awk '{j += $7} END {print j}' > > > > Usage: dirsize And very handy it is too, even without compressed ZFS, thanks Andrew. cheers, Ian