home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / shell / 3803 < prev    next >
Encoding:
Text File  |  1992-09-03  |  2.9 KB  |  87 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!usenet.coe.montana.edu!news.u.washington.edu!hardy.u.washington.edu!micah
  3. From: micah@hardy.u.washington.edu (Micah Anderson)
  4. Subject: Could someone help me with script?
  5. Message-ID: <1992Sep3.151142.27136@u.washington.edu>
  6. Summary: what can I do to fix this?
  7. Keywords: script problem
  8. Sender: news@u.washington.edu (USENET News System)
  9. Organization: University of Washington
  10. Date: Thu, 3 Sep 1992 15:11:42 GMT
  11. Lines: 74
  12.  
  13. I run the They Might Be Giants mailing list which has over 260 users on
  14. it, I am trying to make it much easier for me to subscribe and unsubscibe
  15. users, I wrote this script to make the addition of users easier, but it
  16. doesn't always work... comments are in brakets.
  17.  
  18. #/bin/sh
  19. #new.exe - adds new users to master list and mails them info files
  20.  
  21. #look for duplicates in new list and remove
  22. [what I do is go through all my mail and put all the addresses of people
  23. who want to subscribe into a file called new, I want to check to see that
  24. I don't have the same address in more than once - the problem with this
  25. is if there is no duplicate address and the file new.uniq is empty, it just
  26. sits there... any suggestions?]
  27.  
  28. sort new > new.sort
  29. uniq -d new.sort > new.uniq
  30. grep -v `cat new.uniq` new.sort > new.tmp
  31. cat new.uniq >> new.tmp
  32. rm new.uniq
  33. rm new.sort
  34.  
  35. #mail info files to new users
  36. mail `cat new.tmp` < Welcome
  37. mail `cat new.tmp` < tmbg.info
  38.  
  39. #add new users to master list
  40. cat new.tmp >> /com/mailer/TMBG/USERS
  41.  
  42. #check for duplicates in master list and remove
  43. [here I am attempting to do the same thing as above, looking for duplicate
  44. addresses, if an address is in more than once they get twice as much mail,
  45. and is a big hassle...]
  46.  
  47. sort /com/mailer/TMBG/USERS > /com/mailer/TMBG/USERS.sort
  48. uniq -d /com/mailer/TMBG/USERS.sort > /com/mailer/TMBG/USERS.uniq
  49. grep -v `cat /com/mailer/TMBG/USERS.uniq` /com/mailer/TMBG/USERS.sort > USRS.tmp
  50. cat /com/mailer/TMBG/USERS.uniq >> USRS.tmp
  51. mv USRS.tmp /com/mailer/TMBG/USERS
  52. rm /com/mailer/TMBG/USERS.sort
  53. rm USRS.tmp
  54.  
  55. #output info to the log
  56. [here I would like to also output errors (duplicate addresses) into the file
  57. uniq -c will give me a 2 infront of any address that is repeated, BUT if
  58. an address has a 2 in it, I cannot grep for the 2... here to explain a little
  59. better: 
  60. Ok, I am attempting to log when I have duplicates in a file, so I have this:
  61.  
  62. uniq -c new.sort|grep 2 > new.log
  63.  
  64. and I get something like:
  65.  
  66.  more new.log
  67.       2 kavitzp@nickel.brooks.af.mil
  68.       1 xgg2356@dcmdc.dla.mil
  69.  
  70. the first one is fine (as there were two of those and I needed to know that)
  71. but the second one just has a 2 in the address... how can I check just for the
  72. number in the beginning?]
  73.  
  74. date >> new.log
  75. wc -l new >> new.log
  76. echo ' ' >> new.log
  77. cat new >> new.log
  78. echo '------------------------------'>> new.log
  79. rm new.tmp
  80.  
  81.  
  82. any comments or suggestions to make this better are more than appreciated!
  83.  
  84. Thanks!
  85.  
  86.  
  87.