[TriLUG] [bash] get total size of list of directories?

Matt Pusateri mpusateri at wickedtrails.com
Sun Apr 13 20:26:43 EDT 2008


Tom Roche wrote:
> Can one get the total size of a list of directories via shell
> scripting? I know I can do something like
>
> $ find /this -maxdepth 1 -type d | grep -ve 
> '/this$\|norThat$\|norTheOther$' | xargs du -hs
>
> but that just gives me the size of each dir in the list, and
>
> $ find /this -maxdepth 1 -type d | grep -ve 
> 'this$\|norThat$\|norTheOther' | du -hs
>
> fails oddly: value reported is wildly low, so I suspect it's just
> getting one directory then returning. How to get the sum of all?
>
> TIA, Tom Roche <Tom_Roche at pobox.com> first trilug post from my eee!
>   
Add a -c to your du command to get a total.



More information about the TriLUG mailing list