I want to replace and remove a substring from a text file line by line. The info I want to change is under a specific field. For example, I have the following text:
{name:x, version:1.0, info:"test", ...}
{name:y, version:0.1, info:"test again", ...}
{name:z, version:1.1, info:"test over", ...}
{name:x, info: "test", ..., version:1.2, ...}
The field could in random order. I want to remove all the version value and replace all the info value by some specific string, we say "foo".
The expect result:
{name:x, info:"foo", ...}
{name:y, info:"foo", ...}
{name:z, info:"foo", ...}
{name:x, info:"foo", ...}
Is there smart way to do this by shell script? I have no idea how could I replace a substring as above?
I know some stupid command as
sed 's/info:\([^,}]*\)/info:\"foo\"/' file
sed 's/version:\([^,}]*\)//' file