Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ames.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!godot!harvard!seismo!hao!ames!jaw From: jaw@ames.UUCP (James A. Woods) Newsgroups: net.unix,net.wanted.sources Subject: directory tree display using one command line Message-ID: <692@ames.UUCP> Date: Wed, 12-Dec-84 00:57:17 EST Article-I.D.: ames.692 Posted: Wed Dec 12 00:57:17 1984 Date-Received: Fri, 14-Dec-84 06:26:48 EST Distribution: net Organization: NASA-Ames Research Center, Mtn. View, CA Lines: 24 Xref: watmath net.unix:3099 net.wanted.sources:206 # 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)