Date: Fri, 15 Jun 2007 15:46:53 +0300 From: Nikos Vassiliadis <nvass@teledomenet.gr> To: Olivier Regnier <oregnier@oregnier.net> Cc: freebsd-questions@freebsd.org Subject: Re: problem with sed command and csh Message-ID: <200706151546.55080.nvass@teledomenet.gr> In-Reply-To: <467284F9.7090005@oregnier.net> References: <467269EE.6090001@oregnier.net> <200706151404.47348.nvass@teledomenet.gr> <467284F9.7090005@oregnier.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 15 June 2007 15:24, Olivier Regnier wrote: > Nikos Vassiliadis a écrit : > > 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. > > E.g. > > 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@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 > > Thank for you anserw but the result is bad again :) > I tryed this : sed "s/MAKE_ARGS\([^{]*\){/MAKE_ARGS\1{\n\t'mail\/nbsmtp' > => 'WITH_IPV6=1 WITH_SSL=1',/" > /usr/local/etc/pkgtools.conf > but i have this with cat /usr/local/etc/pkgtools.conf > > MAKE_ARGS = {nt'mail/nbsmtp' => 'WITH_IPV6=1 WITH_SSL=1', > } > > Sed and csh is strange no ? I think \n \t not supported by csh. No, its sed. You cannot use backslash notation with BSD sed. nik:0:~$ sed "s/foo/\t\n/" foo tn You can use a literal tab character, but not a literal newline character... How about this? nik:0:~$ echo foo | awk '{ sub(/foo/, "foo\n\tbar"); print; }' foo bar HTH, Nikos
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706151546.55080.nvass>