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 '19 at 13:03
  • 1
    OP would like to display tree dirs with sizes Sep 12 '19 at 13:05
0

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/-/|/'

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.