I need to do what's described below, in bash script.
Let's say I have a file containing text:
Some text foo
Some text foo, another text foo
I want to replace foo with another string but ended with the index of foo in the line
So I want the output to be:
Some text bar1
Some text bar1, another text bar2