Link to home
Start Free TrialLog in
Avatar of StevenHook

asked on

How can I get du to only report folders larger than a certain size?

I want to drill down on space usage on my web server, see which folders are hiding chunkc of junk.
I tried to :
root@GENIUS:~# du --max-depth=10 /var/www/virtual/ > /var/www/virtual/folderlist.csv
but there are just too many folders. the file grows too huge too fast.
Is there a way I can get du to only report if a folder size is more than - lets say - 1GB?
I also thought I should put it in a cron to mail me if ever it finds stuff that's suspicious.
but at the moment I just want it to clean stuff.
Avatar of woolmilkporc
Flag of Germany image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This command will show folders bigger than 1G

find /var -type d -exec du -h {} \; | sort -u | grep ^[0-9.]*G
1.3G    /var/cache/squid/0B
1.4G    /var/cache/squid/00
1.3G    /var/cache/squid/0E
1.8G    /var/cache/squid/07
1.6G    /var/cache/squid/02
2.6G    /var/cache/squid/01
1.8G    /var/cache/squid/09
1.4G    /var/cache/squid/0A
1.2G    /var/cache/squid/03
1.4G    /var/cache/squid/0C
2.2G    /var/cache/squid/08

Open in new window

Avatar of StevenHook


Thanks so much for the help
It worked great.
I used the du one.
Won't grep ^[0-9.]*G putput anything that contains a number and an uppercase G in it?
there are MANY such folders.
It will not as it looks for a number right in the beginning which is the foldersize
will it stop at the tab, or can the G be any * away from the number?
It will stop. *  means 0 or more times the one specified before. Which are numbers and the dot. Would be different if it was "[0-9].*G"
I understand