From owner-freebsd-stable@FreeBSD.ORG Wed Oct 8 07:20:00 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 439611065687 for ; Wed, 8 Oct 2008 07:20:00 +0000 (UTC) (envelope-from lhmwzy@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.152]) by mx1.freebsd.org (Postfix) with ESMTP id C086E8FC16 for ; Wed, 8 Oct 2008 07:19:59 +0000 (UTC) (envelope-from lhmwzy@gmail.com) Received: by fg-out-1718.google.com with SMTP id l26so2494692fgb.35 for ; Wed, 08 Oct 2008 00:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=56l2OQCUDQrom623VeDYoq3stX46VR+A1lNBQBNopeU=; b=BDfz1PS3XAbvFlIiWTuKTLXJ3PDnWU6wuY9VEIyBFI6P6+krW/znsCSMMl9935lclm Sf3f3ON78GqtUxQ7IuZT9+9/qj9oX6HuBQFAUk+P1o1ijld9yjhUvrAExEFRzagOpFbc 6XPRFCosXhR9JI2poHyKO2tDAKAhIB5Y5H664= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=S2Kbeu+9MHaHfZp64S7fleThgZIH6STc9FzLfgQny5WTxo8/04zyZypvFP3kaCTr7T EzEyWVXbD2AiXOTSCkErLWmxnezdAqbKEigVRFJ90+v7gARVZL5NVSavoqSWLZSZJu2r vac8u6ficksizx2MlTBFNmGwK5WNnXAhcNj14= Received: by 10.86.27.19 with SMTP id a19mr7162823fga.37.1223450398543; Wed, 08 Oct 2008 00:19:58 -0700 (PDT) Received: by 10.86.25.10 with HTTP; Wed, 8 Oct 2008 00:19:58 -0700 (PDT) Message-ID: <78fb9d960810080019j3b73e3ffidc189c716fb7a1de@mail.gmail.com> Date: Wed, 8 Oct 2008 15:19:58 +0800 From: lhmwzy To: "Ian Smith" In-Reply-To: <20081008165835.C16723@sola.nimnet.asn.au> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200810071314.45922.max@love2party.net> <48EB5ADD.2090900@modulus.org> <78fb9d960810072118k47a64097yaa486ef5179efb1@mail.gmail.com> <20081008165835.C16723@sola.nimnet.asn.au> Cc: freebsd-stable@freebsd.org 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 07:20:00 -0000 OK.It's my mistake. Improve it again: #!/bin/sh find $1 -type f -ls | awk '{j += $7} END {printf("%.2fM\n",j/1024/1024)}' 2008/10/8 Ian Smith : > 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 >