home *** CD-ROM | disk | FTP | other *** search
/ HTML - Publishing on the Internet / html_cdrom.iso / tools / html / linux / check / rducfila.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1995-01-17  |  2KB  |  48 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. # Runs under best available awk interpreter.
  10. #
  11. case `type gawk` in *gawk ) awkntrp='gawk';;
  12.                         * ) case `type nawk` in *nawk ) awkntrp='nawk';;
  13.                                                     * ) awkntrp='awk';;
  14.                             esac;;
  15. esac
  16. if test $# -lt 1
  17. then
  18.     echo "
  19.  Syntax is:  $0  prefix
  20.  
  21. Where \`\`prefix'' is the common prefix of the .NAME, .HREF, and .SRC files
  22. which are to be reduced." >&2
  23.     exit 1
  24. else
  25.     if test ! \( -s $1.NAME -a -s $1.HREF -a -s $1.SRC \)
  26.     then echo "One or more necessary files don't exist; Exiting..." >&2
  27.          exit 1
  28.     else echo "Sorting and correlating files now... (using $awkntrp)" >&2
  29.     sort < $1.NAME | uniq > $1.QNAME
  30.     sort < $1.HREF | uniq > $1.QHREF
  31.     diff $1.QNAME $1.QHREF > $1.TMP
  32.     $awkntrp '/^< /{print substr($0,3)}' $1.TMP > $1.QHREF
  33.     $awkntrp '/^> /{print substr($0,3)}' $1.TMP > $1.QNAME
  34.     diff $1.QNAME $1.QHREF > $1.TMP                 # Iterate
  35.     $awkntrp '/^< /{print substr($0,3)}' $1.TMP > $1.QHREF
  36.     $awkntrp '/^> /{print substr($0,3)}' $1.TMP > $1.QNAME
  37.     sort < $1.SRC | uniq > $1.TMP
  38.     mv $1.TMP $1.SRC      # You can change this if you don't want
  39.     mv $1.QNAME $1.NAME   # to overwrite the original three files
  40.     mv $1.QHREF $1.HREF
  41.     echo "Shared items were removed from $1.NAME and $1.HREF
  42.  (i.e. external cross-reference checking), and $1.SRC was sorted and
  43.  duplicate items removed.
  44. " >&2
  45.     fi
  46. fi
  47. exit 0
  48.