Path: utzoo!utgpu!watmath!clyde!att!osu-cis!killer!ames!xanth!mcnc!rutgers!netnews.upenn.edu!eecae!mailrus!uflorida!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.unix.questions Subject: Re: 'tree' utility Message-ID: <9339@smoke.BRL.MIL> Date: 11 Jan 89 09:50:21 GMT References: <1351@uswat.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 44 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