[comp.unix.questions] 'tree' utility

gwyn@smoke.BRL.MIL (Doug Gwyn ) (01/11/89)

In article <1351@uswat.UUCP> sheryl@hosa.USWest.COM () writes:
>Looking for utility to graphically illustrate directory structures on Sun
>systems, especially the 'tree' utility.

This isn't quite what you had in mind, but it's simple and universal;
it's also easy to tweak to one's personal liking.  (No prizes for
improving the shell programming style.)

#!/bin/sh
# Install this as command "lsi"

case "$1" in
-[0-9]*)	indent=`expr 0 - $1`
		dir="$2"
		;;
*)		indent=0
		dir="$1"
		;;
esac

if [ "x$dir" = x ]
then	dir=.
fi

nextind=`expr $indent + 1`
prefix=

while [ $indent -gt 0 ]
do	prefix="$prefix"'   '
	indent=`expr $indent - 1`
done

cd "$dir"

for i in *
do	if [ "$i" = '*' ]
	then	exit
	else	if [ -d "$i" ]
		then	echo "$prefix$i"/
			lsi -$nextind "$i"
		else	echo "$prefix$i"
		fi
	fi
done

jbayer@ispi.UUCP (Jonathan Bayer) (01/17/89)

In article <1351@uswat.UUCP> sheryl@hosa.USWest.COM () writes:
>Looking for utility to graphically illustrate directory structures on Sun
>systems, especially the 'tree' utility.


You could try looking at vtree, which I sent to Rich Salz and was
posted in comp.sources.unix several months ago.  Unfortunately I sent
version 2 several months ago, and it has yet to appear.  If you want it
let me know.

JB



-- 
Jonathan Bayer				"The time has come," the Walrus said...
Intelligent Software Products, Inc.	
19 Virginia Ave.				...uunet!ispi!jbayer
Rockville Centre, NY   11570	(516) 766-2867	jbayer@ispi