Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!know!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!peregrine!ccicpg!hobbit!ndjc From: ndjc@hobbit.UUCP (pri=-10 Nick Crossley) Newsgroups: comp.lang.perl Subject: Re: This looks like a job for Perl Man (NNTP) Summary: Shell(!) script for marking old news articles Message-ID: <88197@hobbit.UUCP> Date: 28 Sep 90 08:29:53 GMT References: <20550@orstcs.CS.ORST.EDU> Organization: ICL North America, Irvine, CA 92718 Lines: 81 In article <20550@orstcs.CS.ORST.EDU> pvo@sapphire.OCE.ORST.EDU (Paul O'Neill) writes: >You quickly discover that your .newsrc file is useless because the article >numbers on the new server are different than the article #'s on your >Looks like a bear, but probably manageable in perl. >... >Uh, I don't suppose anyone's already done this? Heh, heh. This is not really what you asked for, but it might be useful to some. Quite some time ago I was having problems on a system where my .newsrc file was lost, or the articles were renumbered, etc. I wrote the following shell script (this was before perl!) which marks as read all articles older than the specified number of days. I have not rewritten this in perl, since I have never needed to run it recently! --------------------- cut here --------------------------- : Mark as read all news articles older than $1 days NEWS=/usr/spool/news V=: case $1 in -v) V=echo ; shift ;; esac case $1 in "") set 2 ;; [0-9]*) : OK ;; *) echo "Usage: $0 [-v] [days]" 1>&2 ; exit 1 ;; esac cp .newsrc savednewsrc { for group in `sed -n 's/:.*//p' <.newsrc` do echo "/^$group:/c" echo "$group: \c" dir=$NEWS/`echo $group | tr '.' '/'` if [ ! -d $dir ] then echo else ( cd $dir ; find . -type f -mtime +$1 -print ) | sed -e 's!\./!!' -e '/\//d' | sort +0n -1 | awk ' NR==1 { srange=1; erange=$1; next } { if ($1 == erange+1) { # continue range erange++ next } else if (srange == erange) printf "%d,",srange else printf "%d-%d,",srange,erange srange=$1 erange=$1 } END { if (erange == 0) printf "\n" else if (srange == erange) printf "%d\n",srange else printf "%d-%d\n",srange,erange } ' fi echo "." $V "$group done" >&2 done echo "w" echo "q" } | ed - .newsrc ---------------------- End of script --------------------------- -- <<< standard disclaimers >>> Nick Crossley, ICL NA, 9801 Muirlands, Irvine, CA 92718-2521, USA 714-458-7282 uunet!ccicpg!ndjc / ndjc@ccicpg.UUCP