[net.unix-wizards] About the Dirtree program

borman (01/18/83)

	Well, I've seen this dirtree program by Greg Ordy, and I saw the
request for a program would skew the output in the other direction.  Well,
I have such a beast.  I've been working on it on and off for the last year.
What I've come up with is quite nice.  It will give you a listing of a directory
structure, you can have it list files also, you can get vital stats and
other goodies. For instance, the following is output from "tree -pv dave:"

        |-alpha---
        |
        |         |-d1-
|-dave:-|-direct--|-d2-
        |-letters-
        |-news----

Next is output from "tree -pvl dave:"

        |-alpha--- d rwx --- ---       sys       1
        |
        |         |-d1- d rwx --- ---       sys       1
|-dave:-|         |     d rwx --- ---       sys       1
        |-direct--|     d rwx --- ---       sys       1
        |         |-d2- d rwx --- ---       sys       1
        |-letters- d rwx --- ---      dave       1
        |-news---- d rwx --- ---      dave       1

Next, we have "tree -apflv dave:"

       |-.log        rw- --- ---      dave       1
       |-.mailrc     rw- --- ---      dave       1
       |-.newsrc     rw- --- ---      dave       1
       |-.profile    rw- --- ---      dave       1
       |-t.c         rw- --- ---      dave       4
       |-alpha---- d rwx --- ---       sys       1
       |
       |          |-.fred      rw- --- ---       sys       0
       |          |-.joe       rw- --- ---       sys       0
       |          |
       |          |         |-fraz     rw- --- ---       sys       0
       |          |         |-harry    rw- --- ---       sys       0
       |-direct---|         |          rw- --- ---       sys       0
       |          |-d1------|          rw- --- ---       sys       0
       |          |         |-john     rw- --- ---       sys       0
|-dave-|          |         |          rw- --- ---       sys       0
       |          |         |-zarf     rw- --- ---       sys       0
       |          |
       |          |         |-.junk    rw- --- ---       sys       0
       |          |-d2------|          rw- --- ---       sys       0
       |                    |-look     rw- --- ---       sys       0
       |
       |          |-fred       rw- --- ---       sys       1
       |-letters--|            rw- --- ---      dave      18
       |          |-joe        rw- --- ---      dave      18
       |          |-pete       rw- --- ---       sys       0
       |
       |          |-4bsd       rw- r-- r--      dave       3
       |          |-mx2.c      rw- r-- r--      dave      37
       |-news-----|            rw- r-- r--      dave       4
                  |-poem       rw- r-- r--      dave       4
                  |-rfc.819    rw- r-- r--      dave      74
                  |-uucp       rw- r-- r--      dave       7

By default, tree makes a tree of the directory structure below the current
directory.  You can specify some other directory if you wish.  Tree takes
several flags:
	'a' include files
	'c length' column length. All columns are truncated to a maximum
	    of length characters, 'v' option may shrink columns even more.
	'd' sort directories first;
	'f' sort files first;
	'l' use long format, printing mode, owner and size;
	'n' do not sort, use order in directory; (if 'f', 'd' & 'n'
	    are not specifed, things are sorted in alphabetical order)
	'p' include files beginning with "." (except for "." and "..")
	's' same as l, but print mode in octal, and userid number instead
	    of username;
	'v' variable length columns. Each column is by default 14 characters
	    wide, 'v' tells it to shrink each column as much as possible
	    without truncating any names.
	'x' do not cross mounted file systems. (Thus you can tree root
	    without unmounting everything)

Tree is written to run on a PDP 11/70 running V7.  If people are interested
I will post the sources.  I've just gotten everything to work right, so the
code is still a bit messy, needing some cleanup.  It stores everthing in
core, so is limited by how much data space it can have.  There is a #define
STATS that can be undefined to give more data space, you just loose the 'l'
and 's' options.  The searching algorithm is pretty straight forward, but
the stuff to print the tree is a bit strange, and could probably be improved
on, but it works.  I was going to wait until I had a nice clean version,
but I'll post a preliminary source if people want it.

			-Dave Borman,	St. Olaf College
			{ihnp4|harpo|minn-ua}!stolaf!borman