Now , I need to first search for the pattern "mos44.0 )" and then TKTS_RELEASE will be some 30 lines below(not 30 always)...
I need to go there and then modify the value of TKTS_RELEASE variable from tkts44.0b7 to tkts44.0b10.
For modifying the contents I can use sed command ...But how do I determine where the changes shud be done...The place where I change shud satisfy two conditions ...1) "mos44.0 )" and then some lines below..TKTS_RELEASE variable..
Can you show a bit more of this file please? Is "mos44.0 )" a kind of label that marks the start of a section? Is there anything else marking a kind of end of that section ie. when replacement should be stopped/not done?
awk '/mos44.0/{f=1}/TKTS_RELEASE=/ && f {sub("tkts44.0b7",tkts44.0b10");f=0} {print}' bmp.config > bmp1.config
awk: syntax error near line 1
awk: bailing out near line 1
grep "mos44.0" file_name && sed 's/tkts44.0b7/tkts44.0b10/' file_name seems to work..but it is modifying TKTS_RELEASE variable to tkts44.0b10 everywhere in the file where it is tkts44.0b7 which is undesirable...What can be done?
sed '/mos44\.0)/,/TKTS_RELEASE/s/TKTS_RELEASE=tkts44\.0b7/TKTS_RELEASE=tkts44.0b10/' file
This will replace the first occurrence of TKTS_RELEASE=tkts44.0b7 after each occurrence of mos44.0)
There are differences between sed dialects so you may or may not need to backslash the closing parenthesis after mos44.0. Or just take it out if there are no other occurrences of this text in the file in cumbersome places.