Sven Guckes maillists-yahoo@guckes.net [sed-users]
2016-01-19 01:06:39 UTC
so my mailer is "mutt" (www.mutt.org) - and it
has this nifty feature of a "display filter",
ie messages get filtered through this program before the
resulting text is shown, so i can change and delete text.
changing allow me to correct those misspelled words and
deleting allows for hiding signature and maillist footers.
i had been using "sed" as my filter for many years now.
the setup for mutt is as easy as this line:
set display_filter="/bin/sed -f /home/user/guckes/.mutt/df.sed"
so.. it's just a simple "set option=value" command.
getting rid of signatures which are delimited by
the sigdashes line (das-dash-space) is dead easy:
/-- /,$d
since that change by yahoo groups my From: line looks like this:
From: "Sven Guckes maillists-***@guckes.net [sed-users]"
fixing this to "name <address>" is easy within sed:
/^From: .*sed-users/s:"\(.*\) \([^ ]*@[^ ]*\) \[sed-users\]".*:\1 <\2>:
but i should also get rid of seeing those footers now..
example:
------------------------------------
Posted by: Sven Guckes <maillists-***@guckes.net>
------------------------------------
deleting this in the vim editor (www.vim.org) is easy:
:/Posted by/-1,/Posted by/+1d
that's because you can do easy arithmetic
on the pattern to get a new line address:
/pattern/-1,/pattern/+1
but how do you do arithmetic with lines in sed again?
how to tell sed to "find the matching line, go back one,
and then delete three (current and next two) lines"?
i am sure the hold and pattern spaces are to be
used here - but i never quite got the hang of it. :-/
maybe this can even be extended to
"delete this paragraph if it contains pattern" or
"delete from line1 to line2 if it contains pattern"?
incidentally - is there some "visualizer"
to show what sed is currently doing?
you know, debugger style and all. ;)
Sven
has this nifty feature of a "display filter",
ie messages get filtered through this program before the
resulting text is shown, so i can change and delete text.
changing allow me to correct those misspelled words and
deleting allows for hiding signature and maillist footers.
i had been using "sed" as my filter for many years now.
the setup for mutt is as easy as this line:
set display_filter="/bin/sed -f /home/user/guckes/.mutt/df.sed"
so.. it's just a simple "set option=value" command.
getting rid of signatures which are delimited by
the sigdashes line (das-dash-space) is dead easy:
/-- /,$d
since that change by yahoo groups my From: line looks like this:
From: "Sven Guckes maillists-***@guckes.net [sed-users]"
fixing this to "name <address>" is easy within sed:
/^From: .*sed-users/s:"\(.*\) \([^ ]*@[^ ]*\) \[sed-users\]".*:\1 <\2>:
but i should also get rid of seeing those footers now..
example:
------------------------------------
Posted by: Sven Guckes <maillists-***@guckes.net>
------------------------------------
deleting this in the vim editor (www.vim.org) is easy:
:/Posted by/-1,/Posted by/+1d
that's because you can do easy arithmetic
on the pattern to get a new line address:
/pattern/-1,/pattern/+1
but how do you do arithmetic with lines in sed again?
how to tell sed to "find the matching line, go back one,
and then delete three (current and next two) lines"?
i am sure the hold and pattern spaces are to be
used here - but i never quite got the hang of it. :-/
maybe this can even be extended to
"delete this paragraph if it contains pattern" or
"delete from line1 to line2 if it contains pattern"?
incidentally - is there some "visualizer"
to show what sed is currently doing?
you know, debugger style and all. ;)
Sven