Firebird News

Tuesday, August 11, 2009

sorting directories by disk usage

I needed to sort directories by disk usage using du and sort , but there was a problem with dirs that start with "-"

$du -s *

gives this error "du: invalid option --"

So i had to put the directory list result in a file:

$ find . -maxdepth 1 -type d -name '*' -print0 >file_list.lst

then i used the --files0-from

$ du -sm --files0-from file_list.lst | sort -n

seems that i needed to show the timestamp --time and maybe to exclude the "thumbs.db" from the report --exclude="thumbs.db"

$ du -sm --exclude="thumbs.db" --time --files0-from file_list.lst | sort -n
Post a Comment