procmail
[Top] [All Lists]

Re: removing line

2002-01-22 13:33:53
On 21 Jan 02, David W. Tamkin (dattier(_at_)ripco(_dot_)com) wrote:
Rikard asked,

| I'm kinda new to this and I wonder how to simply remove a line from the
| body of a message containg a certain sentence or words in a procmail
| filter, before delivering the message.

 :0Bbfw
 * pattern
 | grep -v 'pattern'

That will remove every line that the pattern is on.  If it can appear more
than once and you want to remove only the first occurrence, you can use this
action line instead:

 | sed -e '1,/pattern/{' -e'/pattern/d' -e '}'

If you want to delete only the second, or third, or Nth, or last, it gets a
lot more complicated.

While we're on the subject, how about removing a multi-line block
(like a signature)?

-- 
Stephen Patterson http://www.lexx.uklinux.net/
s(_dot_)patterson(_at_)SPAM(_dot_)freeuk(_dot_)com (remove spam to reply)
ICBM address 54-22-0N 0-28-0W  Linux Counter No: 142831 
GPG Public key: 252B8B37 available on public keyservers.

Attachment: pgpBC7aZc3UYd.pgp
Description: PGP signature

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