lets say I have a string variable variable
var="This line is with OldText"
I want to find and replace the text inside this variable The method that I tried is,
echo $var | sed -i "s/OldText/NewText/g" >> result.log
in this case this gives an error saying "no input files". The expected output is ,
"This line is with NewText"
what is the correct method to do this using sed, awk or any other method.
-ioption from it, its for inplace editing and you are Good to go, cheers.echo $var >> result.log && sed -i "s/OldText/NewText/g" result.log