home | list info | list archive | date index | thread index

Re: looking for particular "tree"-like recursive directory display

On Mon, 24 Feb 2020, Dianne Skoll wrote:

Filtering is the way to go, IMO.  This worked for me on Debian Buster:

tree -F | sed -e 's/|/ /g' -e 's/`/ /g' -e 's/ -- /    /g'

Interestingly, does not work on Ubuntu 18.04. The tree bar elements appear to be real graphic characters.

so instead:
tree -F | sed -e 's/│/ /g' -e 's/`/ /g' -e 's/ ─ /    /g' -e 's/├//' -e 's/└//' -e 's/─//g'

I do love how you can copy and paste stdout UTF8 chars into command line tools. It makes it SO much easier sometimes. As does being able to start a file name with spaces in it with ' and have tab completion nicely complete it without a ton of '\ '

Unless you have files with "|", "`" or " -- " in their names, you should
be safe.

Nah. What are the chances of that...? :-)

(certainly less so, when tree outputs graphic chars that are even less likely to be part of a file or dir name. ya, right... Hmm, those could make a pretty confusing filename, I'll have to try that sometime :-))

Brett