home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / next / misc / 18717 < prev    next >
Encoding:
Text File  |  1992-08-16  |  1.8 KB  |  75 lines

  1. Newsgroups: comp.sys.next.misc
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!smurf.sub.org!incom!orfeo!darkcube!vhs
  3. From: vhs@darkcube.radig.de (Volker Herminghaus-Shirai)
  4. Subject: Re: A "tree" command?
  5. Message-ID: <1992Aug16.114203.12191@darkcube.radig.de>
  6. Sender: vhs@darkcube.radig.de (Volker Herminghaus-Shirai)
  7. Reply-To: vhs@darkcube.radig.de
  8. References: <BssECp.6LM@usenet.ucs.indiana.edu>
  9. Date: Sun, 16 Aug 92 11:42:03 GMT
  10. Lines: 63
  11.  
  12. In article <BssECp.6LM@usenet.ucs.indiana.edu> shulick@yankton.ucs.indiana.edu  
  13. (Sam Hulick) writes:
  14. > I'm looking for an MS-DOS-like "tree" command that will show all the
  15. > directories and files in a graphical representation.  Is there a UNIX command
  16. > that will do this, or is there a 'Tree.app' or something of the like that is
  17. > NeXT-specific and has a better display?  Either is fine.  Thanks.
  18.  
  19. Try one of the following shell scripts:
  20. #!    /bin/sh
  21. #    tree - first version
  22.  
  23. case $# in
  24. 0)    DIR=".";;
  25. 1)    DIR=$1;;
  26. *)    echo usage: $0 [directory]
  27.     exit 1
  28. ;;
  29. esac
  30.  
  31. find $DIR -type d -print 2>/dev/null | awk '
  32. BEGIN { FS="/" }
  33.     a = 1
  34.     while ( a<NF-2 ) {
  35.         printf "|        "
  36.         a++
  37.     }
  38.     if( NF > 2 ) {
  39.         printf "|--------"
  40.     }
  41.     printf "%s\n",$NF
  42. }'
  43. exit 0
  44.  
  45. #!    /bin/sh
  46. #    tree - second version
  47. direct=`pwd`
  48. ls -aFR | grep '^\./' | sed -e '/^\.\/$/d' |
  49.     sed -e sh\./hh -e sh:\$hh | awk -F/ "
  50.     BEGIN {
  51.         print \"Directory tree\n\"
  52.         print \"$direct\n+\n|\"
  53.     }
  54.     {
  55.         i = NF
  56.         while (i > 1) {
  57.             printf \"|    \"
  58.             i--
  59.         }
  60.         printf \"+-%s/\\n\", \$NF
  61.     }
  62.     END {
  63.         printf \"%d subdirectories\n\", NR
  64.     }"
  65. exit 0
  66.  
  67. --
  68. Volker Herminghaus-Shirai (vhs@qb.rhein-main.de)
  69.  
  70. Computer industry: Industry in which the number of units sold of any
  71. given product is inversely proportional to its technical excellence.
  72. See also: MS-DOS, Windows, IBM-PC, X, QWERTY, 80x86.
  73.