procmail
[Top] [All Lists]

Re: stripping 'footer ads' from mailing lists

2000-04-01 09:46:15
Darren Wyn Rees asked,

| what is the most prudent way of stripping
| footer ads placed in 'free' mailing lists ?

| is sed the best tool for this job ?

That depends on particulars.  Since head is going to be a smaller binary
than sed, head may be more efficient, in exchange for a little more work
inside procmail.  In these examples, the assumption is that "pattern" is
on the first line to be dropped; if "pattern" is on the last line to be
kept, make the commented replacements:

  :0
  * ()\/pattern(.*$)*
# if pattern should be kept, use this instead of above:
# * pattern.*$\/(.*$)*
  {
   FOOTER=$MATCH

   :0
   * 1^1 B ?? ^.*$
   * -1^1 FOOTER ?? ^.*$
   { KEEPLINES = $= }

   :0bfi
   | head -$KEEPLINES
  }

Otherwise, you can use sed:

 :0bfi
 * pattern
 | sed -n '/pattern/q' -ep
#| sed '/pattern/q' # instead of above if pattern should be kept

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