problem with sed command and csh

Nikos Vassiliadis nvass at
Fri Jun 15 11:06:01 UTC 2007

On Friday 15 June 2007 13:29, Olivier Regnier wrote:
> Hi everybody,
> Actually, i'm working on FreeBSD 6.2 and csh shell. With a sh script, i
> trying to execute this command :
> sed -e "s/MAKE_ARGS\([^{]*\){/MAKE_ARGS\1{\n\t'mail/nbsmtp' =>
> 'WITH_IPV6=1 WITH_SSL=1',/" > /usr/local/etc/pkgtools.conf
> The result is not correct, i have an error :
> sed: 1: "s/MAKE_ARGS\([^{]*\){/M . . .": bad flag in subsitute command:
> 'n'
> Can you help me please ?

s/MAKE_ARGS\([^{]*\){/MAKE_ARGS\1{\n\t'mail/nbsmtp' =>
This n is invalid--------------------------^^^

You should add a backslash before each slash
that is not used as a separator for the s command.
s/I want to substitute the \/ character/with the _ character/
s/\/\/\//three slashes/

You can also use a separator of choice for the s command.
That is:
s/foo/bar/ is equivalent to s at foo@bar@
is equivalent to sAfooAbarA
is equivalent to s1foo1bar1.

keep in mind, that our sed might not be
totally compatible with GNU sed.

HTH, Nikos

More information about the freebsd-questions mailing list