Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In Linux, I know I can use

find ./ -size +1M

to find files which are bigger than 1M, but how do I sum the total space needed by these files?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can -execute a program on each of the find results.

-exec utility [argument ...] {} +

Same as -exec, except that ``{}'' is replaced with as many pathnames as possible for each invocation of utility. This behaviour is similar to that of xargs(1).

Run du -c to sum of disk usage (number of used blocks) on the results, like this:

find ./ -size +1M -exec du -c {} +

Optionally add -h to get human readable sizes, or -k for 1k blocks. Add -s if a different find expression also returns folders.

This requires that there aren't too many results, since it builds a single du call from the file names, and if that gets too long, it'll split it up into separate calls with separate totals.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.