🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.admin.technical
2 messages
2 total messages Started by Gregory G. Woodbury Mon, 25 Jan 1993 02:40
Scanning out the "For your newsgroups file:" line
#60
Author: Gregory G. Woodbury
Date: Mon, 25 Jan 1993 02:40
82 lines
3206 bytes
Last week I posted an inquiry for a piece of sed or other code that
would give me the line FOLLOWING the "For your newsgroups file:" line
that David Lawrence (tale@uunet.uu.net) and other place in the newgroup
messages for NetNews.

I figured that it would be a simple one liner or so, but it turns out to
be a rather subtle bit of code.

All three of the responses I got are basically the same bit of code from
the INN newgroup script.  Two are from the released versions, and David
sent the latest and greatest from uunet.

John Schmitz answered first with:
	>From duke!dtc.hp.com!schmitz%scd.hp.com  Mon Jan 18 15:36:03 1993
	>Date: Mon, 18 Jan 1993 10:36:47 -0800
	>From: John Schmitz <duke!dtc.hp.com!schmitz%scd.hp.com>

${SED} <${ARTICLE} >>${NEWSGROUPS} -n -e '
        :top
        /^For your newsgroups file:$/b print
        n;b top
        :print
        n;p;q'

Then David Lawrence sent this version:
	>From duke!uunet.uu.net!tale  Mon Jan 18 22:51:35 1993
	>From: duke!uunet.uu.net!tale (David C Lawrence)
	>Date: Mon, 18 Jan 93 17:00:27 -0500

This is how INN does it:

${SED} <${ARTICLE} >>${NEWSGROUPS} -n -e "
:top
/^For your newsgroups file:\$/b scan
n
b top
:scan
n
/$1[    ]/ {
p
q
}
b scan"

And finally Ken Sallenger sent this (edited) comment and code fragment.
	>From duke!animal.csd.scarolina.edu!ken  Thu Jan 21 15:36:53 1993
	>Date: Thu, 21 Jan 93 15:08:42 EST
	>From: Ken Sallenger <duke!animal.csd.scarolina.edu!ken>

I append a fragment from the INN newgroup script.  It's not that
simple (for me at least).  I had to read the sed(1) man page
very carefully, several times, to be sure I understood this one!

The comment is mine; the GNU sed that I was using made a real
hash out of the end of our newsgroups file, so I switched back
to /bin/sed.

==== INN code courtesy of Rich Salz, INN version 1.2 ====
# USC-kws Tue Dec 22 15:47:27 EST 1992
#
#  Substituting /bin/sed for GNU sed, as we get bad results.
#  Specifically, printing was *on* from BOF to the newsgroups line,
#  the line prints OK, then OK (i.e. no printing) to EOF.
#
case $WORD in
created)
    /bin/sed <${ARTICLE} >>${NEWSGROUPS} -n -e '
        :top
        /^For your newsgroups file:$/b print
        n;b top
        :print
        n;p;q'
    ;;
esac

My thanks to the respondents, and to Rich Salz (the presumed author of
the code in question.)
-- 
Gregory G. Woodbury @ The Wolves Den UNIX, Durham NC  <Standard disclaimers>
UUCP: ...dukcds!wolves!ggw   ...duke!wolves!ggw           [use the maps!]
Domain: ggw@wolves.Durham.NC.US  ggw%wolves@duke.cs.duke.edu
[This site is *not* affiliated with Duke University.  (Idiots!) ]
Re: Scanning out the "For your newsgroups file:" line
#62
Author: Mark Brader
Date: Mon, 25 Jan 1993 17:45
22 lines
1351 bytes
[Side note: the article to which this is a followup had "Followup-To:
news.admin.misc", even though the topic is technical, and there was
no explanation of this in the text.  I hope this was simply an error
by the original poster, which the moderator didn't notice.]

> Last week I posted an inquiry for a piece of sed or other code that
> would give me the line FOLLOWING the "For your newsgroups file:" line...
> I figured that it would be a simple one liner or so ...

And so it is, if you use awk rather than sed.  In new awk:

	awk '/^For your newsgroups file:/ {getline; print; exit}'

In old awk, I believe it takes two lines:

	awk '/^For your newsgroups file:/ {hit = NR+1}
	     NR == hit {print; exit}'
-- 
Mark Brader, Toronto		sed -e "s;??\\([-=(/)'<!>]\\);?\\\\?\\1;g"
utzoo!sq!msb, msb@sq.com	will fix them...	-- Karl Heuer

This article is in the public domain.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads