2

is there a nice way to combine:

ls -R | grep "^[.]/" | sed -e "s/:$//" -e "s/[^\/]*\//--/g" -e "s/^/   |/"

(displays directory as tree)

with

du -h ... (for each listed dir)

Without installing any extra package, like tree, dutree ?

2
  • What do you mean by "combine"? Sep 12, 2019 at 13:03
  • 1
    OP would like to display tree dirs with sizes Sep 12, 2019 at 13:05

1 Answer 1

1

I think, you should revert the order of du -h with tac and then put some formatting with sed. This one should work for "normal" directory names (without control characters):

du -h | tac | sed 's_[^/[:cntrl:]]*/_--_g;s/-/|/'

Or use find -exec:

find . -type d -exec du -sm {} \; | sed 's_[^/[:cntrl:]]*/_--_g;s/-/|/'

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .