I need to go through thousands of files and find lines that start with
On these lines I need to look for a series of keywords, namely
fileinto_copy followed by
After those keywords I need to modify the PATTERN and replace
PATTERN can consist of almost any character e.g.
simple.folder.structure more.complex.[department_1] @employee-XY
The parts between the keywords can vary slightly and the whole "keywords+PATTERN" pattern can occur multiple times in one line.
It sounds easy but I couldn't figure out a way to make it work with
awk without writing a big script and take apart the lines. I think I'm half decent with
sed to replace stuff and also to find patterns, but I don't know how to limit the replacement to only the PATTERN.
Any suggestions in what I could use to do this, without writing a longer script? Is there maybe a way with
sed capture groups?
Update: As some may have figured out, the files need to be modified because of a migration. We knew that the new software is not fully compatible but as it turns out the above mentioned lines "# disabledRule" are not recognised by the new software at all, hence rendering the problem unsolvable from this perspective.