Path: utzoo!attcan!uunet!crdgw1!rpi!julius.cs.uiuc.edu!apple!rutgers!att!cbnewse!danj1 From: Dan_Jacobson@ATT.COM Newsgroups: comp.unix.shell Subject: Re: Rebuild a .newsrc file Message-ID: Date: 5 Oct 90 03:53:08 GMT References: <2713@crdos1.crd.ge.COM> <1990Oct3.014039.27275@cbnews.att.com> <1990Oct4.154607.4767@ibmpcug.co.uk> Sender: danj1@cbnewse.att.com (Dan Jacobson) Organization: AT&T-BL, Naperville IL, USA Lines: 144 In-Reply-To: dylan@ibmpcug.co.uk's message of 4 Oct 90 15:46:07 GMT Mine takes regular expressions of your liked/disliked groups and sorts the .newsrc. Since it depends on sed/awk, etc, I noticed it poops out on long lines, so I stopped using it. Plus now that I'm using GNUS, I hope to find a more high tech solution. [Cheapest shar, and signature at end...] echo x - newsrc-rx sed 's/^X//' >newsrc-rx <<'*-*-END-of-newsrc-rx-*-*' X# regular expressions for my home-made newsrc sorter. Dan_Jacobson@ATT.COM X# this file holds the "loved" newsgroups regular expressions X# `#' is a comment character at beginning of line. X# [Was] Always being refined, sloppy, order not too signifigant, especially X# further down. X X#if .newsrc lines are too long, screws up. X X# Loacl issues, and emergency stuff, etc. X^general|important X^ih X^att X^chi X X# Things that are going to make my job easier, or pointers to job-easers X#^gnu\\.(announce|bash|misc|utils|ghost|emacs|gdb) Xgnu Xemacs|editors X\\.tex[^a-z] Xcomp\\.(fonts|text) X\\.sun Xblit|tty5620 X#comp\\.dcom\\.(modems|telecom) Xalt\\.sources Xcomp\\.sources(:|\\.d|\\.misc|\\.unix|\\.wanted) Xarchive Xcomp\\.unix X#bugs\\.(sys5|bsd|sun) Xbugs X^news\\.announce\\.new X^news\\.(lists|newusers) Xsecurity|\\.doc X\\.x[.:] X X#Things that make life easier X Xtelecom Xcomp\\.risks Xsci\\.(med|lang) Xrec\\.travel|driving Xastro X#comp\\.org Xrec\\.food\\.veg Xconsumers X#backcountry X\\.mail X#asian|china|culture|korean|africa Xnews Xculture Xmusic Xlegal Xenvironment X\\.invest|\\.taxes Xgnu X#^comp Xconference X^sci X#^rec X^soc X^list X#^alt X#^misc X#^talk *-*-END-of-newsrc-rx-*-* echo x - newsrc-rx-kill sed 's/^X//' >newsrc-rx-kill <<'*-*-END-of-newsrc-rx-kill-*-*' X# Dan_Jacobson@ATT.COM X# this file holds the "hated" newsgroups regular expressions X#these go to the bottom of $NEWSRC X\\.amiga|\\.atari|\\.ibm|\\.binaries|\\.test|sport|games|^ak\\. X^al\\.|^alc\\.|^an\\.|^atl\\.|^bionet\\. X^biz\\.|^cb\\.|^control|^dr\\.|^er\\.|^essug\\.|^ga\\.|^hl\\.|^ho\\.|^in\\. X^junk|^lc\\.|^mh\\.|^ne\\.|^nj\\.|^oh\\.|^pk\\.|^pr\\.|^princeton\\.|^rd\\. X^sf\\.|^unix-pc\\.|^wb\\.|^wh\\.|^wi\\.|^inh\\.|philosophy|\\.cray|\\.msdos X\\.xenix|\\.sco[.:]|\\.vms:|^att\\.(lib|jobdigest)|physics|ps-maps|\\.aix X\\.aux|[234]86|\\.ultrix *-*-END-of-newsrc-rx-kill-*-* echo x - rcsrt sed 's/^X//' >rcsrt <<'*-*-END-of-rcsrt-*-*' X: Dan_Jacobson@ATT.COM. Sort .newsrc file my style. Last edit: 8/1990 Xtrap '' 1 15 #best? Xset -xe #quit on error X: ${NEWSRC=$HOME/.newsrc} Xreg_exp_file=${1-$HOME/newsrc-rx} #a file full of regular expression strings Xin=/tmp/$$in out=/tmp/$$out X#backup=$HOME/NEWSRC$$ Xbackup=/usr/tmp/.NEWSRC$$ Xkill_file=$HOME/newsrc-rx-kill Xtrash=/tmp/$$trash Xtest -f "$reg_exp_file" -a -f "$NEWSRC" -a $# -lt 2 -a ! -f $in -a ! -f \ X $out -a ! -f $backup -a ! -f $trash Xcp $NEWSRC $backup && compress $backup #be thrifty on disk space Xcp $NEWSRC $in Xset +e X#for reg_exp in `cat $reg_exp_file` #but *blanks* & newlines separate words X X#put the junk at bottom Xtest -f $kill_file && X{ Xexec 3<$kill_file Xwhile read reg_exp <&3 Xdo X case "$reg_exp" in \#*|'') continue;; esac # "#" is comment character X #blank lines with no spaces ok too. X egrep "$reg_exp" $in >> $trash X egrep -v "$reg_exp" $in > $in.tmp X mv $in.tmp $in Xdone X} X Xexec 3<"$reg_exp_file" Xwhile read reg_exp <&3 Xdo X case "$reg_exp" in \#*|'') continue;; esac X egrep "$reg_exp" $in | sort >> $out X egrep -v "$reg_exp" $in > $in.tmp X mv $in.tmp $in Xdone Xset -e X{ cat $out; sort $in; cat $trash;} > $NEWSRC Xrm $out $in $trash X X X Xexit X#to make a test file... Xset -ex Xcp .newsrc NEWSRC-REAL Xsed 's/\([:!]\).*/\1/' NEWSRC-REAL > .newsrc Xrcsrt Xsed 's/\([:!]\).*/\1/' NEWSRC-REAL | diff - .newsrc *-*-END-of-rcsrt-*-* exit -- Dan_Jacobson@ATT.COM Naperville IL USA +1 708-979-6364