Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Dec 2007 00:49:58 +0200
From:      "Halid Faith" <maslak@ihlas.net.tr>
To:        <freebsd-questions@freebsd.org>
Subject:   Re: How to replace two strings in a file in the same time with sed command ?
Message-ID:  <001201c83c48$28b1c530$dc96eed5@ihlasnetym>
References:  <002801c83c11$cd434e70$dc96eed5@ihlasnetym>	<475EC318.90104@dial.pipex.com><001001c83c33$669b46b0$dc96eed5@ihlasnetym> <475EFF89.9040406@web.de>

next in thread | previous in thread | raw e-mail | index | archive | help
I get an error;
sed: illegal option -- d
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file
...]

here's my script
 for i in $(cat /usr/path/test1);
 do
 sed -e s#old1#new1\ cut -d, -f 1 ${i}# -e s#old2#cut -d, -f 3 ${i}#   file1
>  file2
 done

cat test1
boby, e, 656a,
allen, e, 987c,
...

----- Original Message ----- 
From: "Tino Engel" <elrap@web.de>
To: "Halid Faith" <maslak@ihlas.net.tr>
Cc: <freebsd-questions@freebsd.org>
Sent: Tuesday, December 11, 2007 11:22 PM
Subject: Re: How to replace two strings in a file in the same time with sed
command ?


> Halid Faith schrieb:
> > Ok
> > But I have another problem,
> > I couldn't use any command  interior of sed command. That's to say I
have a
> > script;
> >
> > yy="file5"
> >  for i in `cat file1`;
> >  do
> >  sed -e 's/old1/new1\ \'$i'/g' -e 's/old2/'cut -d, -f 1 ${yy}'/g'
file2 >
> > file3
> >  done
> >
> > When I run the script,  I get an error, due to using cut command
> >
> >
> >
> >
> For using environment variables in sed, you have to use # instead of /
>
> VAR="TEXT"
>
> sed s#OLD#${VAR}#g file1
>
> Will replace OLD by TEXT. Do not use quotations here...
> Rg, Tino
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to
"freebsd-questions-unsubscribe@freebsd.org"
>




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001201c83c48$28b1c530$dc96eed5>