home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3337 / cfstrip.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1991-05-17  |  686 b   |  39 lines

  1. #!/bin/sh
  2. # usage:
  3. #    cfstrip <infile >outfile
  4. # Bruce Barnett
  5. #
  6. # this file strips out all comments from a sendmail.cf file
  7. # it also converts 
  8. #    <tab>[whitespace]     to     <tab>
  9. #    <space>[whitespace]    to    <space>
  10. #    <space>$        to    $
  11. #    <space><        to    <
  12. #    <space>@        to    @
  13. case  $#  in
  14.     0)
  15.         ;;
  16.     *)
  17.         echo no arguments are allowed;
  18.         exit 1
  19.         ;;
  20. esac
  21. sed -e '
  22. s/^#.*//
  23. s/^\(R[^    ]*[    ][    ]*[^    ]*\)[    ]*.*$/\1/
  24. s/^\(R[^    ]*[    ][    ]*[^    ]*\)[    ]*$/\1/
  25. s/^\(R[^    ]*[    ][    ]*[^    ]*\)$/\1/
  26. s/    [     ]*/    /g
  27. s/ [     ]*/ /g
  28. s/ \$/$/g
  29. s/ </</g
  30. s/ @/@/g
  31. # convert multiple tabs into one tab
  32. s/        */    /g
  33. # this one will really remove most spaces
  34. s/^R\([^ ]*\) \([^ ]*\)/R\1\2/g
  35. # remove a space in "T root"
  36. s/^T */T/
  37. /^[     ]*$/d
  38.