Using sed, how do I search for a line ending with foo and then edit the next line if it starts with #bar?
Or put another way, I want to remove a comment # from the next line if it starts with #bar and the previous line ends in foo.
For example:
This is a line ending in foo
#bar is commented out
There are many lines ending in foo
#bar commented out again
I tried:
sed -i 's/^foo\n#bar/foo\nbar/' infile