🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
5 messages
5 total messages Started by Will Fiveash Thu, 20 Oct 1994 00:06
Handy .newsrc Unix type script
#12012
Author: Will Fiveash
Date: Thu, 20 Oct 1994 00:06
20 lines
1547 bytes
I use a ksh script to help me when I want to move newsgroups around via
trn.  The script (I call it gnewsrc) takes a group name and prints out
the location followed by the newsgroup that matches the name.  Here is
the script:

  egrep -n "$1" ~/.newsrc|sed 's/:/ /'|awk '{ $1=$1-1; print $1 ":" $2;}'

and here is an usage example:
  $ gnewsrc 'ultrix'
  1389:comp.unix.ultrix:
  8743:umn.local-lists.techc-ultrix-vms!

If I wanted umn.local-lists.techc-ultrix-vms to follow comp.unix.ultrix
I would use trn to move umn.local-lists.techc-ultrix-vms to 1390.
Note, since egrep is used you can use regular expressions as
arguments.  Perhaps someone with trn macro skills can do something
macro-ish with this.
-- 
Will Fiveash,  "My opinions above, facts below."
Internet:  will@austin.ibm.com 
Re: Handy .newsrc Unix type script
#12037
Author: Doctor Lizardo
Date: Fri, 21 Oct 1994 04:29
13 lines
1220 bytes
Will Fiveash <will@austin.ibm.com> wrote:
>The script (I call it gnewsrc) takes a group name and prints out
>the location followed by the newsgroup that matches the name.

My version of grep (Linux) does exactly that with -n.  SunOS's grep
does so as well.  All you'd need to do is:

grep -n keyword ~/.newsrc

And you get the same output without having to muck about with sed & awk.

-- 
Dr. Lizardo <lizardo@net-abuse.org>
Re: Handy .newsrc Unix type script
#12073
Author: Will Fiveash
Date: Mon, 24 Oct 1994 16:35
26 lines
1782 bytes
In article <387g30$2oq@oak.zilker.net>,
Doctor Lizardo <lizardo@rotten.tic.com> wrote:

>My version of grep (Linux) does exactly that with -n.  SunOS's grep
>does so as well.  All you'd need to do is:
>
>grep -n keyword ~/.newsrc
>
>And you get the same output without having to muck about with sed & awk.

AIX grep understands -n as well but the problem is with the starting
line number in .newsrc. In AIX,

  $ grep -n flight .newsrc
   165:comp.sys.ibm.pc.games.flight-sim: 1-26069

while my command returns
   164:comp.sys.ibm.pc.games.flight-sim:

Trn uses 0 as the starting line number and my shell script compensates
for this.  The other issue is that if you have a group where the
articles read are not contiguous the grep output can be messy.

-- 
Will Fiveash,  "My opinions above, facts below."
Internet:  will@austin.ibm.com 
Re: Handy .newsrc Unix type script
#12113
Author: Per Hedeland
Date: Tue, 25 Oct 1994 22:27
23 lines
1742 bytes
In article <Cy6rFC.1y5J@austin.ibm.com> will@austin.ibm.com (Will Fiveash) writes:
>In article <387g30$2oq@oak.zilker.net>,
>AIX grep understands -n as well but the problem is with the starting
>line number in .newsrc. In AIX,
>
>  $ grep -n flight .newsrc
>   165:comp.sys.ibm.pc.games.flight-sim: 1-26069
>
>while my command returns
>   164:comp.sys.ibm.pc.games.flight-sim:
>
>Trn uses 0 as the starting line number and my shell script compensates
>for this.  The other issue is that if you have a group where the
>articles read are not contiguous the grep output can be messy.

But you don't need to run three programs for it:

awk /"$1"/'{print NR-1 ":" $1}' $HOME/.newsrc

--Per Hedeland
per@erix.ericsson.se  or
per%erix.ericsson.se@sunic.sunet.se  or
..uunet!erix.ericsson.se!per
Re: Handy .newsrc Unix type script
#12273
Author: Will Fiveash
Date: Mon, 31 Oct 1994 19:15
26 lines
1868 bytes
In article <38k0oo$pvc@euas20.eua.ericsson.se>,
Per Hedeland <per@erix.ericsson.se> wrote:
>In article <Cy6rFC.1y5J@austin.ibm.com> will@austin.ibm.com (Will Fiveash) writes:
>>
>>Trn uses 0 as the starting line number and my shell script compensates
>>for this.  The other issue is that if you have a group where the
>>articles read are not contiguous the grep output can be messy.
>
>But you don't need to run three programs for it:
>
>awk /"$1"/'{print NR-1 ":" $1}' $HOME/.newsrc

On AIX v3.2.5 the above command returns:
awk: Input line misc.forsale: 1-3710 cannot be longer than 3,000 bytes.

 The input line number is 702. The file is /u/will/.newsrc.
 The source line number is 1.

But I did get it to work using "cut" like so:

cut -f1 -d' ' $HOME/.newsrc|awk /"$1"/'{print NR-1 ":" $1}'

Thanks for the tip.
-- 
Will Fiveash,  "My opinions above, facts below."
Internet:  will@austin.ibm.com 
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