Thursday, 15 August 2013

How to find a character and replace the entire line in a text file

How to find a character and replace the entire line in a text file

How would I go into a text file find a certain character then replace the
entire line that the character was on?
Here's an example of the text file:
line1
example line2
others
......
....
id: "RandomStr"
more lines
...
I need to find the line with "id" and replace it. The edited text file
should be:
line1
example line2
others
......
....
"The correct line"
more lines
...

No comments:

Post a Comment