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

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

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

These Might Interest You

  • Revised approach to and3k's version, using pipes and read rather than command substitution. This does not require fiddling with IFS when paths have whitespace, and does not risk hitting command-line size limits. It's less verbose on the missing files, but it stops iterating at the first file that's missing, so it should be definitely faster. I expanded all the qlist options to be more self-describing.


    3
    emerge -av1 `qlist --installed --nocolor | uniq | while read cp; do qlist --exact $cp | while read file; do test -e $file || { echo $cp; echo "$cp: missing $file (and maybe more)" 1>&2; break; }; done; done`
    Flameeyes · 2010-07-04 19:55:42 2
  • When running a long `diff -r` over folders, this simulates a "verbose" mode where you can see where diff is in the tree. Replace $file with the first part of the path being compared.


    2
    lsof -c diff -o -r1 | grep $file
    d0g · 2014-01-29 18:35:28 1
  • Shows a tree view of parent to child processes in the output of ps (linux). Similar output can be achieved with pstree (also linux) or ptree (Solaris). Show Sample Output


    4
    ps auxf
    systemj · 2009-02-05 18:07:16 0
  • I got really tired of having tree always show me tons of .svn and .git stuff that I don't care about. With this alias, "tree" uses pretty colors, snazzy line graphics, and ignores any source control and package mumbojumbo. (Customize the *.*.package glob, of course.) Show Sample Output


    7
    alias tree="tree -CAFa -I 'CVS|*.*.package|.svn|.git' --dirsfirst"
    isaacs · 2009-03-27 05:13:39 0
  • An easy function to get a process tree listing (very detailed) for all the processes of any gived user. This function is also in my http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html Show Sample Output


    4
    psu(){ command ps -Hcl -F S f -u ${1:-$USER}; }
    AskApache · 2009-11-13 06:10:33 1
  • This loops through all installed ebuilds and checks if every file that should be installed is still there and if not adds it to emerge. It includes a verbose output to stderr too. If you have packages installed that have whitespace in their filenames you have to change the IFS to "newline".


    1
    emerge -av1 $(for e in `qlist -I --nocolor | uniq`; do for f in `qlist -e $e`; do if test ! -e $f; then echo $e; echo $e: missing $f 1>&2; fi; done; done)
    and3k · 2010-07-04 18:23:59 0

What Others Think

I know there are other commands doing the same thing even in this site, but this one is smaller/shorter ;-)
JesusSuperstar · 480 weeks ago
?What about tree command (available in "tree" package in debian)? ;)
Malkavian · 480 weeks ago
Why anyone would want to simulate DOS is beyond me.
atoponce · 479 weeks and 6 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 · 467 weeks and 5 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: