I have a directory with the following subdirectories, i.e. If I run $ tree -L 1
.
├── 2007-06-20_to_2008-10-01
├── 2008-07-21_to_2008_08_12-Nokia 2mp
├── 2009-11-01_to_2011-01-10 - All iphone Pics
├── 2011-01-01 palliser-pics
├── 2011-03-10_to_2011-04-12-few iphone pics b4 switch to HTC
└── 2011-03-31-to-2013-05-01 ALL HTC pics-backup-prior-to-factory-reset
I would like to see the amount of diskspace those 2 directories and all their contents take up.
e.g. desired output, something like
2.7G 2007-06-20_to_2008-10-01
200MB 2008-07-21_to_2008_08_12-Nokia 2mp
1.3G 2009-11-01_to_2011-01-10 - All iphone Pics
667MB 2011-01-01 palliser-pics
2.3G 2011-03-10_to_2011-04-12-few iphone pics b4 switch to HTC
123MB 2011-03-31-to-2013-05-01 ALL HTC pics-backup-prior-to-factory-reset
So I have been trying:
find . -maxdepth 1 -type d | xargs du -h
but because some of the directory names contain spaces each line from the find output is producing many WORD's before being passed to xargs, is it possible to fix this?
I know the root cause of the problem is caused by the spaces in the files, and I will use rename to fix if I cant find a way to get disksize with du, find and xargs
find . ! -name . -prune -type d -exec du -h {} +– mikeserv Nov 15 '15 at 06:06{} +seemed to fix the looping issue - but its still printing the subdir's? – the_velour_fog Nov 15 '15 at 06:15dudoes its own path traversal. userdu -shto summarize each argument. – mikeserv Nov 15 '15 at 06:19duonce producing one line of output containing the grand total for all directories. I guess-execis the only option - but its obviously tricky to predict what arguments its going to use – the_velour_fog Nov 15 '15 at 06:24findmatch do you want exactly then? – mikeserv Nov 15 '15 at 06:24find . -path '*/*/*/*' -prune -type -d -exec du -sh {} +– mikeserv Nov 15 '15 at 06:29find . -maxdepth 1 -type d -execdir du -sh {} +to work thanks - if you post as an answer - I would accept it – the_velour_fog Nov 15 '15 at 06:47-parg '*/*/*/*'? but you can post an answer, too, you know. – mikeserv Nov 15 '15 at 06:49