Avatar of StevenHook
StevenHook
 asked on

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

Hi,
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.
Thanks
Steve
LinuxLinux DistributionsIT Administration

Avatar of undefined
Last Comment
StevenHook

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
woolmilkporc

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Chris Sandrini

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

StevenHook

ASKER
Thanks so much for the help
It worked great.
I used the du one.
StevenHook

ASKER
Won't grep ^[0-9.]*G putput anything that contains a number and an uppercase G in it?
there are MANY such folders.
Steve
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Chris Sandrini

It will not as it looks for a number right in the beginning which is the foldersize
StevenHook

ASKER
will it stop at the tab, or can the G be any * away from the number?
Chris Sandrini

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"
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
StevenHook

ASKER
Ok,
Thanks.
I understand