Example,
Trying to replace text to the end of a line.
Text file looks like this
PP= 4
PP= 412
PP= 425
I want to replace only the following line:
PP= 4
with
PP= 2
How can this be done with sed?
Example,
Trying to replace text to the end of a line.
Text file looks like this
PP= 4
PP= 412
PP= 425
I want to replace only the following line:
PP= 4
with
PP= 2
How can this be done with sed?
sed 's/4$/2/' filename
sed s/"PP= 4"$/"PP= 2"/
between the " " whatever you want to replace
(edit: added the $
after the varontron remarks, varontron is right without it will change all PP= 4[whatever])
you need the '$' on the end of the pattern if you want only the line ending in '4' to be changed. Phil_FL's suggestion will change all the lines containing the pattern, not just the first.