I've a file with multiple lines. I'm looking for help to modify only these lines that are matching the regex pattern and then add some text after each result. I use a mac but the bash script will run on linux, I don't know if it is relevant.
i.e
someText
StringToSearch:
| isoCode |
someOthertext
StringToSearch:
| isoCode |
againSomOtherText
StringToSearch:
| isoCode |
after matching "StringToSearch:" I need to add "| uk |" after each "| isoCode |" so the result will be something like:
someText
StringToSearch:
| isoCode |
| uk |
someOtherText
StringToSearch:
| isoCode |
| uk |
againSomeOtherText
StringToSearch:
| isoCode |
| uk |
My regex is ^\s*StringToSearch:\n[^\n]+ and a full working example is available at regex101 following the link
I can't figure out how to implement it in bash using sed.
Actually my sed looks like this: sed -E 's,\^\s*StringToSearch:\n\([^\n]+\),| uk |,' < inputFile