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 <[EMAIL PROTECTED]>: > >> 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 _______________________________________________ freebsd-stable@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-stable To unsubscribe, send any mail to "[EMAIL PROTECTED]"