Problem statement: replace every Nth occurrence of a pattern. For bonus points, provide context to the match. For this article, we're going to use this example (mostly nonsensical, but that illustrates the concept): 1foo1 bar foo 2foo3 abc def foo foo foo 1foo4 foo foo 3foo9 4foo7 zzz 7foo7 3foo3 And we want, among all [...]
Archive of posts filed under the faq category.
Text replacement in context/out of context
An added twist to the usual search/replace problems.
Look for multiple patterns in files
One of the most FAQ of all times.
“In-place” editing of files
Temporary files don't bite, so just use them.
Joining files with awk
Join lines from files based on keys




