Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Dec 2009 21:04:28 -0700 (MST)
From:      Warren Block <wblock@wonkity.com>
To:        Martin McCormick <martin@dc.cis.okstate.edu>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: sed -f Script Syntax 
Message-ID:  <alpine.BSF.2.00.0912162052270.98796@wonkity.com>
In-Reply-To: <200912170320.nBH3KatB081365@dc.cis.okstate.edu>
References:  <200912170320.nBH3KatB081365@dc.cis.okstate.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 16 Dec 2009, Martin McCormick wrote:

> Warren Block writes:
>> sed(1) says it should be -E. Looks like it will only work on the whole
>> script.
>
> 	Many thanks. I have had -e work many times

But -e does not mean what you think here:

-E      Interpret regular expressions as extended (modern) regular
         expressions rather than basic regular expressions (BREs).  The
         re_format(7) manual page fully describes both formats.

-e command
         Append the editing commands specified by the command argument to
         the list of commands.

So sed -E means "interpret regular expressions as extended" and -e is 
followed by a command:

sed -E -e 's/a/b/' -e 's/x/y/'

> if you call sed from either the command line or a shell script as in
>
> sed -f somefile
>
> with somefile being 1 or more lines of sed commands. When the
> file itself is the script, the first line actually calls sed
> from within the file.

I'm not clear on why you want to do it that way instead of simply 
calling sed from a shell script, but sed -Ef seems to do what you want.

-Warren Block * Rapid City, South Dakota USA



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.0912162052270.98796>