zfs quota question

Ian Smith smithi at nimnet.asn.au
Wed Oct 8 06:43:54 UTC 2008


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 at 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


More information about the freebsd-stable mailing list