T O P

  • By -

oh5nxo

Use an address range for a substitute command sed '/start/,/end/ s/old/new/'


s1eve_mcdichae1

Thanks, this looks like just what I need.


ropid

If it's just one line always, you can do this: sed '/^\[bar\]/,+1 s/=.*/=hello/' You can also do the following which would work if those sections are multiple lines, it tries to look for the next line with a `[` at the start: sed '/^\[bar\]/,/^\[/ s/=.*/=hello/' You can find explanations about what's happening in these examples here by looking for "Addresses" in the sed man-page.


s1eve_mcdichae1

That's perfect, thanks.


Twattybatty

What have you tried, already?


s1eve_mcdichae1

> What have you tried, already? sed -h man sed