I am trying to add text to the end of a line the first x times it occurs. I know how to do it globally and for the n occurrence. I can't figure out how to do it for the first nth occurrences. An example would be a text.txt file that contains:
This is a test
junk
This is a test
More junk
This is a test
This is a test
This is a test
And, I want to add a '.' at the end of the first three times that "This is a test" occurs. The output I am trying to get is:
This is a test.
junk
This is a test.
More junk
This is a test.
This is a test
This is a test