I have a food.txt file as follows :-
mangoes|foo|faa oranges|foo|faa chocolates|foo|baz
I am trying to replace foo with bar if condition baz is met. (would like to use a regular expression here b*z )
Currently using the sed command below, but this does not directly modify the existing file. I am also not able to use a regular expression (b*z).
sed '/baz/s/foo/bar/g' food.txt
Please suggest a way other than "sed" to modify the existing file directly.
PS : I tried
sed -i but I would like to use some other command than sed.
I am using mobaxterm (OS - Windows)