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

Jim Ray jim at neuse.net
Sun Apr 13 22:03:30 EDT 2008


I thought all you did was right click on properties :-)


> -----Original Message-----
> From: trilug-bounces at trilug.org [mailto:trilug-bounces at trilug.org] On
> Behalf Of Nick Goldwater
> Sent: Sunday, April 13, 2008 9:53 PM
> To: Triangle Linux Users Group General Discussion
> Subject: Re: [TriLUG] [bash] get total size of list of directories?
> 
> Below will give you the size of the folder:
> du --si -S /path/to/folder/
> 
> This will present a list of folder sizes:
> #!/bin/bash
> if [ “a$1″ != “a” ]; then
> cd $1
> fi
> du --si */ .[^.]*/ | sort -n | while read a; do echo ” $a”; done | sed
> -r 's/^\ *([\ 0-9]{3})([\ 0-9]{3})([ 0-9]{3})\ *(.*)\/$/\1 \2 \3 \4/' |
> egrep -v "k\ "
> 
> Nick
> 
> ----- "Tom Roche" <Tom_Roche at pobox.com> 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!
> | --
> | TriLUG mailing list        :
> | http://www.trilug.org/mailman/listinfo/trilug
> | TriLUG Organizational FAQ  : http://trilug.org/faq/
> | TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
> --
> TriLUG mailing list        :
> http://www.trilug.org/mailman/listinfo/trilug
> TriLUG Organizational FAQ  : http://trilug.org/faq/
> TriLUG Member Services FAQ : http://members.trilug.org/services_faq/



More information about the TriLUG mailing list