For instance, I have a large filesystem that is filling up faster than I expected. So I look for what's being added:
find /rapidly_shrinking_drive/ -type f -mtime -1 -ls | less
And I find, well, lots of stuff. Thousands of files of six-seven types. I can single out a type and count them:
find /rapidly_shrinking_drive/ -name "*offender1*" -mtime -1 -ls | wc -l
but what I'd really like is to be able to get the total size on disk of these files:
find /rapidly_shrinking_drive/ -name "*offender1*" -mtime -1 | howmuchspace
I'm open to a Perl one-liner for this, if someone's got one, but I'm not going to use any solution that involves a multi-line script, or File::Find.
The command
du
tells you about disk usage. Example usage for your specific case:(Previously I wrote
du -hs
, but on my machine that appears to disregardfind
's input and instead summarises the size of the cwd.)You could also use
ls -l
to find their size, thenawk
to extract the size:I have tried all this commands but no luck. So I have found this one that gives me an answer:
with GNU find,
Darn, Stephan202 is right. I didn't think about du -s (summarize), so instead I used awk:
I like the other answer better though, and it's almost certainly more efficient.
I'd like to promote jason's comment above to the status of answer, because I believe it's the most mnemonic (though not the most generic, if you really gotta have the file list specified by
find
):