What command can display files in a tree?

Is there a command that displays a certain path of files in a tree just like the dos command 'tree'?

Maybe something like:

find . -type d -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
4 Likes

those don't look like valid commands.

Before dismissing a response out of hand, it's best to at least try the proposed solution. I ran Perderabo's code and got a nice looking tree.

I confirm that Perderabo's code works perfectly!

And, WOW!!

That command truly impressed me :eek:

I've never thought that could be possible displaying a tree with a simple sed command :slight_smile:

that sed command worked perfectly fine

Thanks. Now that I'm at home I can actually try the command. Sorry, it didn't look like valid arguments before.

The sed command keeps saying that it needs a proper command after the -e option. I looked on the man page for commands, but whenever I tried any of them, it wouldn't work. The find command worked perfectly though.

Yes man .
there is command like tree in solaris.

it is pstree..it will list your process and shells in a tree format

That command didn't work for me and I actually tried it this time.

Your comments indicate that the code is somewhat alien to you, so you're probably mistyping it. Cut and paste if you're having difficulty with it. It is just a simple sed command and I have tested it on many OS's. I have just cut it from this thread and pasted it into a Solaris xterm and it worked yet again for me.

Very cool command. I'm trying it on OSX 10.5.2 and it's displaying all the folders but not the files. Can anyone help me adjust the command so I see file names too?
Thanks.

Drop the -type flag

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

Perfect, thank you so much!
:b:

WOW, i never knew this command, thansk a lot

Thanks guys. They all ended up working for me. I was typing them wrong.

You can save some keystrokes:

find .  | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
1 Like

Really a nice code...thanks cordially...