Article View: comp.unix.shell
Article #1485Re: Parsing a news article with source in it
From: Tom Christiansen
Date: Fri, 12 Oct 1990 13:42
Date: Fri, 12 Oct 1990 13:42
29 lines
1631 bytes
1631 bytes
In article <838@redford.UUCP> bill@redford.UUCP (Bill Poitras(X258)) writes:
>What I am trying to do is pipe a news article through a shell script
>(preferable /bin/sh) so that it parses the header, extracts the filename
>from the "Archive: ..." line, and then writes the rest of the file,
>from the '!# /bin/sh' line to the end to filename specified in the
>"Archive: ..." line. I can't seem to get the shell script to read up to
>the !# /bin/sh using <<. There are basically two tasks:
> 1) Parsing the header, extracting the filename in the Archive line
> 2) Writing the rest of the file to the filename gotten from #1
>Does such a script exist? Any help would greatly be appreciated.
It does now. :-)
#!/usr/bin/perl -n
if (1 .. /^$/) {
die "can't write to $1: $!" if /^Archive:\s*(\S+)/ && !open(STDOUT, ">$1");
} elsif (/^!#\s*\/bin\/sh/ .. eof) {
print;
}
I'd actually feel more confortable if I had some sample input, but
I believe this matches your spec.
--tom
--
"UNIX was never designed to keep people from doing stupid things, because
that policy would also keep them from doing clever things." [Doug Gwyn]
Technical Details
Message-ID:
<107116@convex.convex.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!convex!convex.COMReferences:
<838@redford.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.unix.shell Subject: Re: Parsing a news article with source in it Message-ID: <107116@convex.convex.com> Date: 12 Oct 90 13:42:44 GMT References: <838@redford.UUCP> Sender: usenet@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 29