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

next in thread | previous in thread | raw e-mail | index | archive | help
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 <smithi@nimnet.asn.au>:
> 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?78fb9d960810080019j3b73e3ffidc189c716fb7a1de>