sed: search and replace string with line number

Posted by tigerstyle on Stack Overflow See other posts from Stack Overflow or by tigerstyle
Published on 2010-05-11T08:31:38Z Indexed on 2010/05/11 8:34 UTC
Read the original article Hit count: 211

Filed under:
|
|
|
|

Hi volks,

I have a XML file with a lot of empty tag attributes. For instance:

<mytag id="">
  <ontent>aaa</content>
</mytag>
<mytag id="">
  <ontent>bbb</content>
</mytag>
<mytag id="">
  <ontent>ccc</content>
</mytag>

Now I want to replace id="" with e.g. id="2443" (id="[linenumber]")

I tried to do this with sed, but I did not get a successful result.

I hope someone here can help me :-)

© Stack Overflow or respective owner

Related posts about sed

Related posts about replace