I can't solve what I want using the tree
, du
, or df
commands.
I'm using:
du
version 9.6tree
version 2.2.1
What I want:
For the current directory, list all directories recursively to a depth of 3, showing their size and ordering them by size. For clarity, each level of subdirectory ought to be indented.
Using du -h -d 3
does not provide a tree view.
Now, tree
seems to be the command to use, but I do not understand the output, so I made a test directory and here are the outputs.
In the following, I do not understand the answer with
tree --du -h -L 2
for the directory size.tree --du -h -L 3
for the directory size ofimmo2
as is 16M and not 4.0K, as well asimmo
and root size 102M and not 86M.
Remark:
tree --du -h -L 2
and tree -du -h -L 2
do not provide the same output.
Thanks.
$ tree --du -h -L 3
[ 86M] .
└── [ 86M] sub1
├── [3.6M] immo
│ ├── [ 670] 00Tree.html
│ ├── [416K] 2013-08-27_120009.jpg
│ ├── [3.2M] 2014-04-09_093940.jpg
│ └── [4.0K] immo_2
└── [ 82M] ogg
├── [ 141] 00Tree.html
└── [ 82M] 2020-06-21.ogg
86M used in 5 directories, 5 files
$
$ tree --du -h -L 2
[4.0K] .
└── [4.0K] sub1
├── [4.0K] immo
└── [ 0] ogg
4.0K used in 4 directories, 0 files
$
$ du -h -d 3
16M ./sub1/immo/immo_2
20M ./sub1/immo
83M ./sub1/ogg
102M ./sub1
102M .
$
P.S. In the meantime,
1/ filed a bug report for tree cmd.
2/ I found an awesome app: https://apps.kde.org/fr/filelight/
tree --du -L 2
only shows the sizes of things that it shows, not things below the given depth.