🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.misc
Article #2429

Re: A "tree" command?

#2429
From: Volker Herminghaus-Shirai
Date: Sun, 16 Aug 1992 11:42
63 lines
1869 bytes
In article <BssECp.6LM@usenet.ucs.indiana.edu> shulick@yankton.ucs.indiana.edu  
(Sam Hulick) writes:
> 
> I'm looking for an MS-DOS-like "tree" command that will show all the
> directories and files in a graphical representation.  Is there a UNIX command
> that will do this, or is there a 'Tree.app' or something of the like that is
> NeXT-specific and has a better display?  Either is fine.  Thanks.

Try one of the following shell scripts:
#!	/bin/sh
#	tree - first version

case $# in
0)	DIR=".";;
1)	DIR=$1;;
*)	echo usage: $0 [directory]
	exit 1
;;
esac

find $DIR -type d -print 2>/dev/null | awk '
BEGIN { FS="/" }
{ 
	a = 1
	while ( a<NF-2 ) {
		printf "|        "
		a++
	}
	if( NF > 2 ) {
		printf "|--------"
	}
	printf "%s\n",$NF
}'
exit 0

#!	/bin/sh
#	tree - second version
direct=`pwd`
ls -aFR | grep '^\./' | sed -e '/^\.\/$/d' |
	sed -e sh\./hh -e sh:\$hh | awk -F/ "
	BEGIN {
		print \"Directory tree\n\"
		print \"$direct\n+\n|\"
	}
	{
		i = NF
		while (i > 1) {
			printf \"|    \"
			i--
		}
		printf \"+-%s/\\n\", \$NF
	}
	END {
		printf \"%d subdirectories\n\", NR
	}"
exit 0

--
Volker Herminghaus-Shirai (vhs@qb.rhein-main.de)

Computer industry: Industry in which the number of units sold of any
given product is inversely proportional to its technical excellence.
See also: MS-DOS, Windows, IBM-PC, X, QWERTY, 80x86.
Technical Details
Message-ID: <1992Aug16.114203.12191@darkcube.radig.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!smurf.sub.org!incom!orfeo!darkcube!vhs
References: <BssECp.6LM@usenet.ucs.indiana.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.misc
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!smurf.sub.org!incom!orfeo!darkcube!vhs
From: vhs@darkcube.radig.de (Volker Herminghaus-Shirai)
Subject: Re: A "tree" command?
Message-ID: <1992Aug16.114203.12191@darkcube.radig.de>
Sender: vhs@darkcube.radig.de (Volker Herminghaus-Shirai)
Reply-To: vhs@darkcube.radig.de
References: <BssECp.6LM@usenet.ucs.indiana.edu>
Date: Sun, 16 Aug 92 11:42:03 GMT
Lines: 63