sed -f Script Syntax

Martin McCormick martin at dc.cis.okstate.edu
Wed Dec 16 16:36:47 UTC 2009


If you have a sed script that is executable as in the first line
starts with
#! /usr/bin/sed -f
and the following lines are like:

/this repetitive line/d
/and another repetitive line to go/d

This all works great. You just make the file executable and use
it as a filter if you want to remove any instance of those lines
in text.

	How does one embed a command in this filter to make sed
understand an extended or modern regular expression like:

/part 1[[:space:]]text\/html[[:space:]]/d

This is normally the -e flag but I haven't figured out how to
put it in the script. I would like to either use it to make that
one line show up as an extended regular expression or make sed
run the entire script in the -e mode.

	In this particular case, I have made a 14-line script
called nuisancefilter that vaporizes annoying blocks of text
from  Email messages.

	I have read the man page and it says that this is
possible, but I never quite understood how to apply the commands
to an executable sed script file.  Many thanks.

Martin McCormick WB5AGZ  Stillwater, OK 
Systems Engineer
OSU Information Technology Department Telecommunications Services Group


More information about the freebsd-questions mailing list