How to replace two strings in a file in the same time with sed
command ?
Tino Engel
elrap at web.de
Tue Dec 11 13:21:21 PST 2007
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
More information about the freebsd-questions
mailing list