I am trying to replace a string where a specific condition is true in the same line
I have a file with some lines. I to replace a word (word1) with another (word2) in every line that starts with another word (word3)
For example:
foo moo see
kaa haa qee
foo dee see
uuu ooo rrr
foo dee laa
I want to replace the word "see" with "raa" in every line which begins with "foo". So doing that will result in the lines being like:
foo moo raa
kaa haa qee
foo dee raa
uuu ooo rrr
foo dee laa
I was told that I can use sed to do that but I didn't figure out how to do that.
Please help! (with sed only)