Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Oct 2008 17:43:50 +1100 (EST)
From:      Ian Smith <smithi@nimnet.asn.au>
To:        lhmwzy <lhmwzy@gmail.com>
Cc:        freebsd-stable@freebsd.org, Andrew Snow <andrew@modulus.org>
Subject:   Re: zfs quota question
Message-ID:  <20081008165835.C16723@sola.nimnet.asn.au>
In-Reply-To: <78fb9d960810072118k47a64097yaa486ef5179efb1@mail.gmail.com>
References:  <E1KnA2b-0007ls-8u@dilbert.ticketswitch.com> <200810071314.45922.max@love2party.net> <48EB5ADD.2090900@modulus.org> <78fb9d960810072118k47a64097yaa486ef5179efb1@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <andrew@modulus.org>:
 > >> 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 <path>

And very handy it is too, even without compressed ZFS, thanks Andrew.

cheers, Ian



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081008165835.C16723>