36

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.

/media/
├── [ 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?

38

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
  • 4
    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 '15 at 4:20
1

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]

-4

Please use this code might help you,

$ sudo tree -hF

or

# tree -hF
  • 1
    This does not do what the OP asked, 4 years ago... – dr01 Oct 7 '16 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.