I like tree it's a nice way to display my files and the size of folders/directories. But the -h option only shows the size of the directory, not the cumulative size of its contents.

├── [ 16K]  64D9-E862
│   ├── [8.0K]  downloads

I know for a fact that my external drive has more that 16kB in it.

How can I fix that with tree 1.5? Better yet how do I upgrade to 1.6?

3 Answers 3


Only for tree 1.6 and above

You might want to look at:

man tree

--du For each directory report its size as the accumulation of sizes of all its files and sub-directories (and their files, and so on). The total amount of used space is also given in the final report (like the 'du -c' command.) This option requires tree to read the entire directory tree before emitting it, see BUGS AND NOTES below. Implies -s.

So you should use:

tree --du -h
  • 9
    This for pointing to --du in 1.6. I always use du -h --max-depth= 1 or 2 or maximum 3. Then drill down (cd) into where I want to go, and run the same command agin. When tree is used with -L it counts only directories/and files up to a given level. Comapred to du which calculates all files irrespective of --max-depth parameter, but just prints up to a specified level. It makes tree not helpful for me. Thanks though!
    – Tagar
    Jul 2, 2015 at 4:20
  • 2
    I suggest adding the -a option to output locations which are hidden (start with a dot, e.g. .cache)
    – awatts
    Oct 3, 2019 at 14:26
  • I'm so sad it reports 0 size when I add the -d option. I just want to see directory sizes and not file sizes with tree
    – Shayan
    Mar 12 at 17:30

Adding on the accepted answer... with any substantial number of folders, you are going to potentially get a huge output from that command.

If like me, you are wanting to identify some big folders to purge because you are filling up your drive, you might find it helpful to combine the tree command with a grep to limit it to folders that are Gigabytes in size, saving yourself the need to traipse through the whole output:

tree --du -h | grep G]


Please use this code might help you,

$ sudo tree -hF


# tree -hF
  • 2
    This does not do what the OP asked, 4 years ago...
    – dr_
    Oct 7, 2016 at 9:37

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.