procmail
[Top] [All Lists]

Re: Recognizing Newlines with Sed

2000-06-26 13:01:29
SoloCDM wrote,

| I successfully used "cat <file> | tr -d '\n'"

UUCA!  UUCA!

That should have been

   tr -d '\n/' < file

but to continue,

| on a file that "sed 's/\n//g' <file>" failed to properly recognize.  I need
| sed to effectively recognize newlines or ask that someone provide a perl
| script that will.
|
| Other types used: \d015 (d: decimal), \r, \<newline>, \$, $, .*, *.  I
| even used an ampersand before each one and I updated sed.

As I have explained before, sed reads one line of the input at a time, and
it will never find \n in the pattern space unless you've used a command that
puts another line into the pattern space without removing the one that is
there already, such as N or G.

| Is someone willing to create a perl file for me with the following
| script conditions?
|
| In a message processed with a .procmailrc recipe, I search for two
| lines by devising separate character strings (e.g. xxxxxxx, xxxxxx)
| with wild cards (e.g. ., *) amongst the character strings and a return
| in the middle that connects the two character strings, then remove the
| intended lines with the return found in the message.
|
| If any of you are willing, I need to have it written for processing a
| message in a recipe *and* processing a file and string.

One can do it in sed.  From a shell prompt,

sed ':a
     N
     s/regexp1\nregexp2//
     ta
     P
     $ !D'

Inside a .procmailrc:

   :0Bbwf
   * regexp1^regexp2
   | sed -e :a -eN -e 's/regexp1\nregexp2//' -eta -eP -e '$ !D'


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