procmail
[Top] [All Lists]

Re: formail question

2002-04-23 10:56:23
Ralph Sobek asked,

| If I have header lines as follows:
|
| X-foobar: value1
| X-foobar: value2
| X-foobar: value3
| X-foobar: value4
|
| how do I just delete "X-foobar: value3"?

because

| formail -I X-foobar:
|
| deletes *all* such headers, and
|
| formail -I "X-foobar: value3"
|
| deletes all and just appends "X-foobar: value3"!

That's what would happen.  Ralph had tried,

| :0 fhw
| | (formail -X "" | sed "/$LINE/d")
|
| which effectively _only_ kills the X-foobar: header that was previously
| matched, leaving the others intact.

Filtering the head through formail -X "" does nothing.

 :0fhw
 | sed "/^$LINE$/d"

will do the same job without the piping or the shell invocation.  Probably

 :0fhw
 | grep -vx "$LINE"

is more efficient yet.

I would suggest this, just in case there are regexp magic characters on the
line:

  :0fhw
  | egrep -vx "$\LINE"

Or drop the -x switch if $\LINE is supposed to match part of the line rather
than all of it.  You can add ^ or $ to the expression to anchor $\LINE at one
end or the other.



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