procmail
[Top] [All Lists]

Re: Recognizing Newlines with Sed

2000-06-26 20:34:36
SoloCDM asked,

| What is UUCA?

It's the Useless Use of Cat Award, given when someone cats one file to a pipe
to another program instead of using the "<" redirector to make the second
program just take its input from that file without invoking cat or making the
shell set up a pipe.

| 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.


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