[net.unix] directory tree display using one command line

jaw@ames.UUCP (James A. Woods) (12/12/84)

#  George of the Jungle quote goes here.

     Someone asked about tree printing.  For the sub-problem of displaying
UNIX directory trees, there's always the one-liner (courtesy Doug Kerr of
Informatics General Corp.)

	echo $1; find $1 -type d -print | tr / \\1 | sort -f | tr \\1 / |\
	sed -e s,\^$1,, -e /\^$/d -e "s,[^/]*/, \"	,g"

This just does directories -- if you want all files, take out the "-type d".
Explanation:  it works by substituting tabs for pathname slashes (the
invisible literal tab occurs before the ",g" above); the translits bracketing
the sort helps alphabetize / before [a-zA-Z].  And if you remember that 
other punctuation can replace the slash in ed/sed syntax (as the comma does in
the script), you needn't say "Deadhead Ed had edited it" fifty times fast.

     I find that anything which prints directory trees "vertically" is likely
to be complicated enough to have bugs, as well as being too screen-dependent.

     It will take some CPU time on big directory structures, but if one
runs the Ames Fast File Finder, it can be made near-instantaneous, though
that's another story ...

     -- James A. Woods  {hplabs,hao,ihnp4}!ames!jaw  (jaw@riacs.ARPA)