Unix command to list all directories larger than 10mb

6

1

Is this possible, and what would the command be?

kylex

Posted 2009-10-27T14:52:10.567

Reputation: 575

1Do you mean like, all directories (regardless of at what depth)? Do you mean containing 10mb in the directory itself, or 10 mb in the directory or any subdirectory? – falstro – 2009-10-27T14:55:28.200

all directories at any depth, and the the total file size next to each directory would include it's sub directories. – kylex – 2009-10-27T15:00:59.237

Answers

6

du is the easiest way. Grab the directories of interest with perl.

du -m . | perl -ne '@l = split();print "@l\n" if $l[0]>=10'

ire_and_curses

Posted 2009-10-27T14:52:10.567

Reputation: 1 014

9

du -k /<root-of-interest> | sort -n 

Then look at the tail for the large directories. You want all that are report greater than 10000.

Douglas Leeder

Posted 2009-10-27T14:52:10.567

Reputation: 1 375

du is the way to go. du|xdu makes it more visibile too.. – falstro – 2009-10-27T14:57:42.313

I might type "du --max-depth=1 | sort -g | less" but that's just a personal preference. Of course the "max-depth" flag only exists in GNU du. – CarlF – 2009-10-27T15:45:27.310

1

Do like this:

find {/path/to/directory} -type f -size +{file-size-in-kb}k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

Remember to don´t put the {}'s.

In your case do like this:

find / -type f -size +10000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'

Nathan Campos

Posted 2009-10-27T14:52:10.567

Reputation: 323

3this finds files, not directories – falstro – 2009-10-27T14:56:50.677

Ops, sorry, i didn't see. Sorry! – Nathan Campos – 2009-10-27T14:58:18.443

0

The du answers above are closer to what you want, but you might also want to try out kdirstat. Its a cool gui tool that shows all your dirs, what's in them, what the content is, and has various tools to delete or move files. There's even Windows (WindDirStat) and MacOSX (Disk Inventory X) clones.

Rich Homolka

Posted 2009-10-27T14:52:10.567

Reputation: 27 121