procmail
[Top] [All Lists]

Re: delete matching line from file

2001-03-11 12:07:13
Now, where were we?

|  :0cwi: $HOME/mail_log$LOCKEXT
|  * ^Subject: Re:[  ]+\/[^     ].*
|  | (echo "/$MATCH/d" ; echo wq) | ed -s $HOME/mail_log

| That's still imperfect, because a slash in the subject can mess it up (and
| Aaron's suggested code has the same problem; Tom's would have as well if it
| would have expanded the variable at all).  But I have to run now, so let's
| get back to that later.

OK then.  If Tom knows that a certain character (other than newline) will
absolutely never appear in the extracted subject, he can use it instead of
the slashes.  A control character probably works well for that.  Otherwise,
we need to do something like this and go back to using a temporary file:

  :0cwi:$HOME/mail_log$LOCKEXT
  * ^Subject: Re:[  ]+\/[^      ].*
  | fgrep -v "$MATCH" $HOME/mail_log > /tmp/$LOGNAME.maillog && \
    mv /tmp/$LOGNAME.maillog $HOME/mail_log || rm -f $LOGNAME.maillog
_______________________________________________
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>