How can I insert a set of lines (about 5) into a file at the first place a string is found?
For example:
BestAnimals.txt
dog
I would:
grep to find the line number of the first matchhead to get the text leading up to the matchcattail to get the lines after the matchIt's neither quick, efficient nor elegant. But it's pretty straight-forward, and if the file isn't gigantic and/or you need to do this many times a second, it should be fine.