I want to find all users shown in the /home/
directory whose disk consumption is more than 500MB. The following command works as expected.
cd /home/ && du */ -hs
68K ajay/
902M john/
250M websites/
From the above example, only 902M john/
should be returned.
How can I make the find
command output the same results?
Best Answer
You can't do this only with find, because find acts on individual files, and doesn't have a concept of adding up file sizes. You could pipe the output of find into another tool, but why bother when du does most of the work?
The awk test becomes messy when the "human-readable" suffix in included in the input, because you need to strip off the trailing "M" to do an integer comparison. For the output, personally I'd skip the "M" suffix, but that's what was requested.