From: utzoo!decvax!harpo!ihnp4!ihuxn!res Newsgroups: net.unix-wizards Title: A Shell Procedure for Directory Structure Listing Article-I.D.: ihuxn.211 Posted: Tue Jan 25 12:52:40 1983 Received: Fri Jan 28 05:29:17 1983 Reply-To: res@ihuxn.UUCP (Rich Strebendt) There have been several programs posted to the net to get a listing of the structure of a directory system. The following shell also generates a simple form of such a listing, without all the grand and glorious information about access privileges, size, et al. I have called it catalog ... since it is recursive you should name it likewise, or change the recursive invocation. The instructions are reasonably complete. # catalog - produce complete file structure list from directory # # Parameters: 1: directory name (optional) # 2: indentation string (empty on first call) # # Produces on standard output the file structure emanating from # the current directory. Each descent into a subdirectory # is indicated by further indentation. Directories are indicated # by surrounding [], and executable files are prefaced with a *. # if [ "$1" = "" ] then echo "file structure from directory `pwd`" date echo "\n\n" fi if [ "$1" != "" ] then cd $1 fi for i in * do if test -d $i then echo "${2}[ $i ]" catalog $i "$2 . " else if [ "$i" != '*' ] then if test -x $i then echo "${2} *$i " else echo "${2} $i " fi fi fi done Some sample output follows: file structure from directory /n1/res/bin Tue Jan 25 12:49:44 CST 1983 *fort fortdata *sh [ source ] . fort.c . sh.c . soxpnd.c *soxpnd temp