home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / unix_c / usenet / newnwsrc.sh < prev    next >
Text File  |  1989-03-21  |  2KB  |  58 lines

  1.  8-Aug-85 13:49:10-MDT,1938;000000000001
  2. Return-Path: <unix-sources-request@BRL.ARPA>
  3. Received: from BRL-TGR.ARPA by SIMTEL20.ARPA with TCP; Thu 8 Aug 85 13:48:45-MDT
  4. Received: from usenet by TGR.BRL.ARPA id aa00827; 8 Aug 85 7:48 EDT
  5. From: "Col. G. L. Sicherman" <colonel@ellie.uucp>
  6. Newsgroups: net.sources
  7. Subject: moving a .newsrc
  8. Message-ID: <486@ellie.UUCP>
  9. Date: 7 Aug 85 20:11:42 GMT
  10. To:       unix-sources@BRL-TGR.ARPA
  11.  
  12. :    newnewsrc - make a new .newsrc conform to an old one.
  13. :    Col. G. L. Sicherman.  7 Aug 1985.
  14. :
  15. :    Have you ever moved from one system to another and found that
  16. :    you must customize a whole new .newsrc, because the old system
  17. :    numbered its news articles differently?
  18. :    This script imposes as much of an old .newsrc as possible on
  19. :    a new .newsrc.  Specifically, it disables groups that were
  20. :    disabled on the old system, and arranges groups into the old
  21. :    order.
  22. :
  23. :    usage:    newnewsrc [-e] [-b] [-o] OLD NEW
  24. :
  25. :    -e    Enable disabled groups on NEW that were enabled on OLD.
  26. :    -b    Place groups not found on OLD at beginning of NEW
  27. :            rather than at end.
  28. :    -o    Do not import "option" lines from OLD.
  29. :
  30. :    New file is written to standard output.
  31. :
  32. bflag='10000'
  33. eflag='~'
  34. oflag='=='
  35. while (true) do
  36. case $1 in
  37. -b*)    bflag='70000'; shift;;
  38. -e*)    eflag='!~'; shift;;
  39. -o*)    oflag='!='; shift;;
  40. *) break;
  41. esac
  42. done
  43. if (test 2 != $#) then
  44. echo 'usage: newnewsrc [-e] [-b] [-o] old new' >&2
  45. exit 1
  46. fi
  47. awk '{print "O",NR+'$bflag',$0}' < $1 > /usr/tmp/$$
  48. awk '{print "N",NR+40000,$0}' < $2 | sort +2 -3 +0 - /usr/tmp/$$ |\
  49. awk '$3 !~ /[:!]$/ {if ($1'$oflag'"O") print; next}\
  50. substr($3,0,length($3)-1)==substr(LSTNM,0,length(LSTNM)-1) \
  51. {if ($3'$eflag'/!$/) LSTNM=$3; print $1, $2, LSTNM, LSTRG; F=0; next}\
  52. 0 < F {print LAST; F=0}\
  53. {if ("O"==$1) LSTRG=""; else LSTRG=$4; LSTNM=$3; \
  54. LAST=$1 " " $2 " " LSTNM " " LSTRG; F=1}\
  55. END {if (0<F) print LAST}' | sort -n +1 | sed -e 's/^..[0-9]* *//'
  56. rm /usr/tmp/$$
  57. exit 0
  58.