home *** CD-ROM | disk | FTP | other *** search
/ HTML - Publishing on the Internet / html_cdrom.iso / tools / html / windows / check / rducfilp.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-01-17  |  2KB  |  43 lines

  1. #!/bin/sh
  2. #
  3. # Shell script to remove common items from .HREF and .NAME files, and sort and
  4. # remove duplicates from .SRC file.  Can be used for external cross-reference
  5. # checking with htmlchek, if refsfile= was specified on the command line
  6. # without xref=1 also being specified, or can be used to resolve the output of
  7. # multiple runs of htmlchek with the append=1 option specified.
  8. #
  9. # Uses perl.
  10. #
  11. if test $# -lt 1
  12. then
  13.     echo "
  14.  Syntax is:  $0  prefix
  15.  
  16. Where \`\`prefix'' is the common prefix of the .NAME, .HREF, and .SRC files
  17. which are to be reduced." >&2
  18.     exit 1
  19. else
  20.     if test ! \( -s $1.NAME -a -s $1.HREF -a -s $1.SRC \)
  21.     then echo "One or more necessary files don't exist; Exiting..." >&2
  22.          exit 1
  23.     else echo "Sorting and correlating files now... (using perl)" >&2
  24.     sort < $1.NAME | uniq > $1.QNAME
  25.     sort < $1.HREF | uniq > $1.QHREF
  26.     diff $1.QNAME $1.QHREF > $1.TMP
  27.     perl -ne 'if ($_ =~ /^< /) {print substr($_,2)}' $1.TMP > $1.QHREF
  28.     perl -ne 'if ($_ =~ /^> /) {print substr($_,2)}' $1.TMP > $1.QNAME
  29.     diff $1.QNAME $1.QHREF > $1.TMP                 # Iterate
  30.     perl -ne 'if ($_ =~ /^< /) {print substr($_,2)}' $1.TMP > $1.QHREF
  31.     perl -ne 'if ($_ =~ /^> /) {print substr($_,2)}' $1.TMP > $1.QNAME
  32.     sort < $1.SRC | uniq > $1.TMP
  33.     mv $1.TMP $1.SRC      # You can change this if you don't want
  34.     mv $1.QNAME $1.NAME   # to overwrite the original three files
  35.     mv $1.QHREF $1.HREF
  36.     echo "Shared items were removed from $1.NAME and $1.HREF
  37.  (i.e. external cross-reference checking), and $1.SRC was sorted and
  38.  duplicate items removed.
  39. " >&2
  40.     fi
  41. fi
  42. exit 0
  43.