
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] Command to find directories containing a particular size of data
Hi Dave,
On Sun, Apr 3, 2011 at 12:31 PM, Dave M G <dave@example.com> wrote:
> With this command I can find out the data size of the subdirectories in
> the specified folder:
>
> du -sh /directory/*
>
> With this next command, I can search a whole directory tree for
> individual files of 10MB or more:
>
> find /directory -size +10000k
>
> However, what I'd really like is a sort of combination of the two. I
> want to crawl through a whole directory tree, and find the directories
> that contain 10MB or more of files.
>
> When calculating the size of any one directory, I need to know just the
> total size of *files* in that directory, but not including the sizes of
> subdirectories in that total.
>
> In other words, what I'm trying to find are instances where a specific
> directory contains a zillion tiny files that add up to 10MB or more.
>
> Is there a way to do that?
>
> I hope my question is clear. Thanks for any advice.
Short of writing your own script (in Perl, etc. to crawl through a
directory tree), I don't think there's a way to do it. Maybe you can
use "du" and pipe the output to a script that subtracts all of
subdirectories' size from the directory it is located in... I think
you check if string x is a prefix of y and if so, subtract y's size
from x...not sure.
You can use "du -h -s *" to get a total of all the subdirectories in
the current directory. i.e., it doesn't print the sub-subdirectories,
but include them in the sum.
The find command has a "-type" option and I frequently do a "-type f"
to restrict the search to files. I tried "-type d" just now but I
don't think that's what you want. I think directories don't have a
size, but I could be wrong...
Hope this helps a bit and thanks for the -size option to find. I
never knew about it...found a 1 GB temp file from 2 years ago that I
should have deleted. :-)
Ray
Home |
Main Index |
Thread Index