home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / useful / gencontents.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-01-31  |  1KB  |  54 lines

  1. #! /bin/sh
  2. #
  3.  
  4. tmpd=`date +%j%H%M%S`
  5. tmp1="/tmp/sh1-$tmpd"
  6. tmp2="/tmp/sh2-$tmpd"
  7. tmp3="/tmp/sh3-$tmpd"
  8. egrep "Product-Info$|\.pi$" <$1 >$tmp1
  9. sed <$tmp1 "s:/.*::" | sort | uniq >$tmp2
  10.  
  11. ### Build the root node.
  12.  
  13. # First copy the CONTENTS-header template...
  14.  
  15. cat CONTENTS-header
  16.  
  17. echo "This file tree is organized into several subdirectories.  For an"
  18. echo "index of the files in any subdirectory, click on the appropriate"
  19. echo "name below:"
  20. echo ""
  21.  
  22. for i in `cat $tmp2`
  23. do
  24.     # Note - pdksh doesn't properly expand the embedded tab.
  25.     /bin/echo "\t@{\"$i\" link $i-INDEX}"
  26. done
  27.  
  28. # Finish off the root node.
  29.  
  30. echo "@endnode"
  31.  
  32. ### Now build a node for each of the subdirectories.
  33.  
  34. for i in `cat $tmp2`
  35. do
  36.     echo "@node $i-INDEX \"Index of subdirectory: $i\""
  37.     echo ""    
  38.     echo "For more information about a particular program, click on the name field"
  39.     echo "below:"
  40.     echo ""    
  41.     grep "^$i/" <$1 >$tmp3
  42.     pitool <$tmp3 -b -F "@{\"%-16.16N\" link %N-%V}  %8.8V   %-S\n" -f - - | sort -f | uniq
  43.     echo "@endnode"
  44. done
  45.  
  46. ### Now build the full contents node for each of the original product
  47. ### info files.
  48.  
  49. pitool <$tmp1 -f - -b -F "@node %N-%V \"%S\"\n\n%N    %V    %S\n\n%d\n\nAuthor: %a\nPath: %P\n\n@endnode\n\n" -
  50.  
  51. ### All done, clean up.
  52.  
  53. rm -f $tmp1 $tmp2 $tmp3
  54.