I have a script that reads a file of about 3GB and sends it through a pipeline involving a very small number of replacements in a very small part of the file. To accomplish this with minimal overhead, the script specifies a small known range within which to make the replacements using sed '/begin/,/end/'
.
I would like to add another couple replacements in another small, known, "regex-delimited" range in the same file. If I pipe through sed again, that introduces unnecessary overhead, and won't scale up nicely.
Is there a way to specify two ranges between patterns if I know the order in which they will appear in the file, such that the file only needs to be read once?
Something like 'sed '/begin1/,/end1/ ... /begin2/,/end2/'
is what I have in mind.
The sed manual states
An address range can be specified by specifying two addresses separated by a comma (,).
But it doesn't mention specifying sets of two addresses each.