Feb 15, '06 06:31:00AM • Contributed by: raimondi
This guy found a way to do so, using just ls, grep and sed; pretty neat! Here's the command:
ls -R | grep ":" | sed -e 's/://' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'The author of this useful command even provides a downloadable shell script for the code, and explains how to make a link to ~/bin/tree for those less Unix savvy users. Enjoy!
[robg adds: First, I apologize for the scrolling box, but I didn't want to take any chances on changing the format of the command by inserting a line break, and it was otherwise too wide for display. I'll be the first to admit I don't understand anything in that command past the colon-replacement bit, but it does work quite nicely. Here's a sample of the output, using the shell script from the linked page:
$ tree /Applications | more
/Applications
|-Address Book.app
|---Contents
|-----MacOS
|-----Resources
|-------ABLargeTypeWindow.nib
etc...
You may wish to add | more at the end to page through the output. Or try using > ~/Desktop/mytree.txt at the end to dump the output to a file. I do not, however, recommend doing that with a huge directory such as Applications, unless you have some time to wait. I tried it, and after a few minutes of waiting, wound up with a 1.1mb text file containing 37,000+ rows!]
