How to use cut or awk commands into sed command ?

Giorgos Keramidas keramida at ceid.upatras.gr
Wed Dec 12 17:13:38 PST 2007


On 2007-12-12 23:19, Halid Faith <maslak at ihlas.net.tr> wrote:
> I have a file named file1 which contains some values.
> I want to replace some strings into it, so I use sed command but I get an error.
>
> sed "s#oldstring#`cut -d, -f3 file2`#"  file1
> sed: 1: "s/yenidomain2/f0b2875d- ...": unterminated substitute in regular expression

That's not enough information to help you in a meaningful manner.

* What does `file2' have to do with the replacement strings, and why do
  you use it?

* What are the contents of both files?

* What do you want to replace, and what should it be replaced with?

> also I get an error with awk command into sed;
> sed "s#oldstring#`awk -F, '{print$3}' file2`#"    file1
> sed: 1: "s#yenidomain2#f0b2875d- ...": unterminated substitute in regular expression

That's not very different from the cut-based command.



More information about the freebsd-questions mailing list