Re:Batch editing files with ed
by orivej on Saturday May 12, 2018 @04:17PM
(#17055819)
This problem is easily solved with a regexp that processes the input as a whole, rather than working on it line by line. I had this need often enough that I exported Go regexp engine as a command line tool regrep, which can insert "elephant" after "baz" with:
It only processes standard input, and can not by itself replace the contents of an input file with its output; but another tool, inplace, helps:
[ Parent
| on HN ]
It's close to the idea of structural regular expressions [0]. I'm still waiting for the awk from the paper.