home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- 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
- From: micah@hardy.u.washington.edu (Micah Anderson)
- Subject: Could someone help me with script?
- Message-ID: <1992Sep3.151142.27136@u.washington.edu>
- Summary: what can I do to fix this?
- Keywords: script problem
- Sender: news@u.washington.edu (USENET News System)
- Organization: University of Washington
- Date: Thu, 3 Sep 1992 15:11:42 GMT
- Lines: 74
-
- I run the They Might Be Giants mailing list which has over 260 users on
- it, I am trying to make it much easier for me to subscribe and unsubscibe
- users, I wrote this script to make the addition of users easier, but it
- doesn't always work... comments are in brakets.
-
- #/bin/sh
- #new.exe - adds new users to master list and mails them info files
-
- #look for duplicates in new list and remove
- [what I do is go through all my mail and put all the addresses of people
- who want to subscribe into a file called new, I want to check to see that
- I don't have the same address in more than once - the problem with this
- is if there is no duplicate address and the file new.uniq is empty, it just
- sits there... any suggestions?]
-
- sort new > new.sort
- uniq -d new.sort > new.uniq
- grep -v `cat new.uniq` new.sort > new.tmp
- cat new.uniq >> new.tmp
- rm new.uniq
- rm new.sort
-
- #mail info files to new users
- mail `cat new.tmp` < Welcome
- mail `cat new.tmp` < tmbg.info
-
- #add new users to master list
- cat new.tmp >> /com/mailer/TMBG/USERS
-
- #check for duplicates in master list and remove
- [here I am attempting to do the same thing as above, looking for duplicate
- addresses, if an address is in more than once they get twice as much mail,
- and is a big hassle...]
-
- sort /com/mailer/TMBG/USERS > /com/mailer/TMBG/USERS.sort
- uniq -d /com/mailer/TMBG/USERS.sort > /com/mailer/TMBG/USERS.uniq
- grep -v `cat /com/mailer/TMBG/USERS.uniq` /com/mailer/TMBG/USERS.sort > USRS.tmp
- cat /com/mailer/TMBG/USERS.uniq >> USRS.tmp
- mv USRS.tmp /com/mailer/TMBG/USERS
- rm /com/mailer/TMBG/USERS.sort
- rm USRS.tmp
-
- #output info to the log
- [here I would like to also output errors (duplicate addresses) into the file
- uniq -c will give me a 2 infront of any address that is repeated, BUT if
- an address has a 2 in it, I cannot grep for the 2... here to explain a little
- better:
- Ok, I am attempting to log when I have duplicates in a file, so I have this:
-
- uniq -c new.sort|grep 2 > new.log
-
- and I get something like:
-
- more new.log
- 2 kavitzp@nickel.brooks.af.mil
- 1 xgg2356@dcmdc.dla.mil
-
- the first one is fine (as there were two of those and I needed to know that)
- but the second one just has a 2 in the address... how can I check just for the
- number in the beginning?]
-
- date >> new.log
- wc -l new >> new.log
- echo ' ' >> new.log
- cat new >> new.log
- echo '------------------------------'>> new.log
- rm new.tmp
-
-
- any comments or suggestions to make this better are more than appreciated!
-
- Thanks!
-
-
-