[H-GEN] replacing text between 2 strings
Shaun Nykvist
shaun at kangawallafox.com.au
Thu Jan 9 00:02:27 EST 2003
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
Thanks for this
Yes I am trying to reformat email archives that have been output from a
lyris mail server, and have already gone through many transformations on
both unix and windoze servers. It has become a messy situation with an
early version of lyris creating a txt archive but unable to parse its own
imput when importing them back. I have found a format that Lyris likes and
am trying to reformat them to suit it. Due to research being conducted on
the archives, they need to be re-instated and lyris have been unable to
provide a solution to date
Cheers
Shaun
At 11:11 PM 8/01/2003 -0500, you wrote:
>[ Humbug *General* list - semi-serious discussions about Humbug and ]
>[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
>
>Shaun Nykvist <shaun at kangawallafox.com.au> writes:
>
> > I have about 200 text files where I need to delete the text between
> > multiple occurrences of 2 constant strings. For example
> > Return-Path
> >
> > various text here
> >
> > Date
>
>I'd do this with something like the following:
>
> $ perl -lne'if(m/^Return-Path$/){$seen=1;next}
> if(m/^Date$/){$seen=0;next}
> if($seen==1){next}
> print' A
>
>There are more obtuse ways to do it but that's pretty simple, really.
>
>Then Shaun wrote:
>
> > I have managed to solve part of the problem (thanks to those who
> > responded), however is there a way to insert a line break or carriage
> > return after a specified text string, in a text document.
>
>I assume you mean to insert a blank line after a string?
>
> $ perl -lpe'm/FIXED/ and $_.="\n"'
>
>This turns:
>
> foo
> FIXED
> bar
>
>into:
> foo
> FIXED
>
> bar
>
>Now, as an afterthought, I'm wondering if you're thinking of trying to
>parse or reformat email messages? If so, I hope the messages have a
>consistent format, since one usually can't be assured of the order
>various headers appear in the message. There's no shortage of code in
>a variety of languages you couldn't reuse instead of reinventing the
>wheel.
>
>jason
>--
>``I may have agreed to something involving a goat.'' -- CJ
>
>--
>* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
>* Postings to this list are only accepted from subscribed addresses of
>* lists 'general' or 'general-post'. See http://www.humbug.org.au/
--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'. See http://www.humbug.org.au/
More information about the General
mailing list