simulates the DOS tree command that you might be missing on your Mac or Linux box

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
NOT MINE! Taken from hackzine.com blog. It creates a tree-style output of all the (sub)folders and (sub)files from the current folder and down(deeper) Quoting some of hackzine's words "Murphy Mac sent us a link to a handy find/sed command that simulates the DOS tree command that you might be missing on your Mac or Linux box. [..split...] Like most things I've seen sed do, it does quite a bit in a single line of code and is completely impossible to read. Sure it's just a couple of substitutions, but like a jack in the box, it remains a surprise every time I run it."
Sample Output
$ cd amsn_received
$ find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'
.
|____amsn_received
| |____screenshot1.png
| |____DSCF1171.JPG
| |____DSCF1202.JPG
| |____DSC00887.jpg
| |____DSC00953.jpg
| |____DSC00595.JPG
| |____at92A3.tmp.jpg
| |____ReadMe 1.pdf
| |____Screenshot.png
| |____cpuz.html

-1
2009-03-12 22:25:26

What Others Think

I know there are other commands doing the same thing even in this site, but this one is smaller/shorter ;-)
JesusSuperstar · 497 weeks and 5 days ago
?What about tree command (available in "tree" package in debian)? ;)
Malkavian · 497 weeks and 5 days ago
Why anyone would want to simulate DOS is beyond me.
atoponce · 497 weeks and 4 days ago
Nice! I've been looking for something like this for awhile. For all the Mac users out there you can use the following to exclude all .DS_Store files: cd /ParentDir/ChildDir; find . ! -name ".DS_Store" -print | sed -e 's;[^/]*/;|__;g;s;__|; |;g' > ../ChildTree.txt
NimbusSoftware · 485 weeks and 3 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: