9

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 option -s and -h how ever what I am more interested 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)

5

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

  • 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
17

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)

  • 2
    Too bad --threshold does not work on OS X. – Franklin Yu Sep 17 '16 at 4:15
  • Also not working on RHEL 6.2 – Matthew Moisen Jan 24 '17 at 23:27
  • Also on Ubuntu it says sort -hn hn are incompatible. – Scott Stafford Oct 10 '17 at 16:13
  • 1
    @ScottStafford Thanks for that, typo, fixed. Should have read just sort -h – Mtl Dev Oct 10 '17 at 20:01
  • how to show files over 500KB? (instead of folders) – Alexander Mills Dec 22 '18 at 3:33
11

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 {} \;
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.

  • both the things.Basically I have to make a report and in that I have to represent it in 2 ways both of which you pointed. – Bond Jan 24 '11 at 11:00
  • I think gt5 mentioned above may be what you are looking for. – SabreWolfy Jan 24 '11 at 11:34
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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