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"? Commented Sep 12, 2019 at 13:03
  • 1
    OP would like to display tree dirs with sizes Commented Sep 12, 2019 at 13:05

1 Answer 1

2

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.