I am trying to search for a string and replace a text right next to it.. I know SED can be used to search for a string and replace it.
example given below.
Input file:
Some text
Random option:"To Replace Text"
Output file:
Some text
Random option:"Replaced Text"
I have tried the below.
grep 'option:' inputfile.txt > temp.txt -- so this gives the line with 'option:' to tempfile
$toReplace = cut -c 17-32 tempfile -- this gives the 'TO Replace Text'
sed 's/$toReplace/$toBeReplaced/' inputfile.txt > outfile.txt
I am sending the $toBeReplaced text from command line..
This works but I don't want to go with the cut command as the position may change in actual requirement.