20

I am having a few situations to which I do not see any thing in du man pages.

  1. I want to see files in a sub directory which are larger than a particular size only.

  2. I use du -sh > du_output.txt I see the output as described for options -s and -h.
    However, what I am more interested in, is if the output comes in a format which is say for example

    dir0--->dir1-->dir3-->dir4 | | ->dir2 |-file1 |-file2

If the above is directory layout and I want to just see the size of individual directories in all the subdirectories then what can I do (the depth of each subdirectory is variable)

Mtl Dev
  • 767
  • 7
  • 14
Bond
  • 741
  • 4
  • 11
  • 22

5 Answers5

43

To only show folders over 1GB in size:

du -h --threshold=1G

You may also want to order by size, to easily find the biggest ones.
du -h --threshold=1G | sort -h

(Works on: Ubuntu/Mint.
Does not work on: OSX or RHEL 6.2)

Mtl Dev
  • 767
  • 7
  • 14
15

Use the find command instead. The following example will show you all files that are larger than 10 megabytes:

find -size +10M

You can use du with find like this to see the size of each file:

find -size +10M -exec du -sh {} \;
carson
  • 1,620
  • 11
  • 15
7

I like the gt5 utility. It use the output of du and creates a browsable listing of directories and their sizes and uses a text-mode browser such as links to display the information.

Both programs are available in the Ubuntu repositories: gt5 and links.

gt5 screenshot

Dennis Williamson
  • 60,515
  • 14
  • 113
  • 148
  • Thanks, gt5 looks very interesting it. I'm going to install it now. Of course there is also "baobab" for GUI. – SabreWolfy Jan 24 '11 at 11:34
1

I see the answer by Mtl Dev fit for this question. Since Bond has opened this thread with tag 'linux' and 'ubuntu-10.04'.
Again, du -h --threshold=1G (followed by | sort -h optionally) works perfectly in Ubuntu.

Although, Bond said that,

I do not see any thing in du man pages.

there're two lines in the man page, please refer below.

-t, --threshold=SIZE
exclude entries smaller than SIZE if positive, or entries greater than SIZE if negative

One more thing, I think the exact command line Bond want is something like this,

find . -mindepth 2 -type d | xargs du -sh -t 1G

When -mindepth 1 claims that it should contain the current path, -mindepth 2 will work on your demand.

Below is a demonstration on the popular dataset lisa.

~/dataset/lisa $ find . -mindepth 2 -type d | xargs du -sh -t 1G | sort -h
1.2G    ./aiua120306-0/frameAnnotations-DataLog02142012_002_external_camera.avi_annotations
1.7G    ./aiua120306-1/frameAnnotations-DataLog02142012_003_external_camera.avi_annotations
4.0G    ./negatives/negativePics
6.0G    ./experiments/training

~/dataset/lisa $ find . -mindepth 2 -type d | xargs du -sh -t 1G
4.0G    ./negatives/negativePics
1.2G    ./aiua120306-0/frameAnnotations-DataLog02142012_002_external_camera.avi_annotations
6.0G    ./experiments/training
1.7G    ./aiua120306-1/frameAnnotations-DataLog02142012_003_external_camera.avi_annotations

~/dataset/lisa $ find . -mindepth 2 -type d | xargs du -sh -t 3G
4.0G    ./negatives/negativePics
6.0G    ./experiments/training
David Jung
  • 111
  • 2
0

find /path/to/folder -size +100k

It's not clear if you are wanting to see the size of individual files which are larger than some value, or whether you want to see folders larger than some value.

SabreWolfy
  • 348
  • 2
  • 13