: -----Original Message----- : From: Bertrand Mansion [mailto:[EMAIL PROTECTED] : Sent: Sunday, January 18, 2004 7:56 AM : To: Charles K. Clarkson; [EMAIL PROTECTED] : Subject: Re: Search replace using 2 lines for pattern : : : <[EMAIL PROTECTED]> wrote : : : > Bertrand Mansion <[EMAIL PROTECTED]> wrote: : > : : > [snip] : > : I have tried many times with no success. I can easily change : > : the "Received:" header to be : > : "From [EMAIL PROTECTED]:" but as there : > : are more than one "Received:" header, they all get replaced, : > : which is bad. : > : : > : I think I need a regex that would match "\n\nReceived:" and : > : replace it with "\nFrom xxxxxx\nReceived:". It doesn't seem : > : difficult but I am stuck. : > : : > : I hope someone can help me, I have tried to solve this : for hours... : > : > : > Can you show us what you have? It would make solving this : > much easier. : : Well, I don't have much, I am trying to do it from the command line: : : perl -pi -e "s/\n\nReceived:/\nFrom xxxxxxx\nReceived:/" file.txt : : The archive is 70Mb approx. I am testing on a smaller subset. : This looks so simple and common that I am probably not taking : the problem in : the right way.
I have never understood why one-liners are so popular. Perhaps because I abandoned the command line for the mouse so many years ago. Where is the xxxxxxx coming from? I think you should solve that first, but your current problem is with '-p' which is similar to (ignoring -i for now): while (<>) { s/\n\nReceived:/\nFrom xxxxxxx\nReceived:/; } continue { print or die "-p destination: $!\n"; } If you only need one replacement, you need to adjust this to stop after the first success. HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>