'tree' utility
    Doug Gwyn  
    gwyn at smoke.BRL.MIL
       
    Wed Jan 11 19:50:21 AEST 1989
    
    
  
In article <1351 at uswat.UUCP> sheryl at 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
    
    
More information about the Comp.unix.questions
mailing list