procmail
[Top] [All Lists]

Re: Recognizing Newlines with Sed

2000-06-27 15:31:28
"David W. Tamkin" wrote:

SoloCDM asked,

| That's much like what a friend of mine put together to remove "\n"
| along with text:
|
|         #!/usr/bin/sed -f
|         /top/{
|         N
|         s/top\( \|\n\)bottom/top\1bottom/
|         P
|         D
|         }

Originally, I had it check ahead only on matches to /regexp1$/, but to sim-
plify the code I took that out and had it check every pair of lines.

The \| construct is not a good idea; many seds do not support it.  But as you
see, \n is there only because after the N instruction there are more than one
line in the pattern space.

What is strange is that your friend's code says to replace the space or the
newline with itself: in other words, to make no change at all.  According to
your previous post, you wanted the newline and the two expressions deleted.

If you want my suggested code in a sed script file, it could be just like
that, except that the s instruction should read

  s/top\nbottom//

with a null replacement string, if I understood your goal correctly.

Correct.  That's what I did.  I placed the whole syntax for anyone
else to use and modified it for what I needed on this network.

Thanks!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

*********************************************************************
Signed,
SoloCDM

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>