I'm trying to pre-process an invoice file and separate each invoice into separate files. The invoices may be multi-page. The header of EACH PAGE looks like this:
121084 A134 09.17.19 1
There are 6 blank lines at the top of each page, followed by the invoice #, customer #, date and page # (then the rest of the invoice).
At each " 1" (70 spaces followed by "1") on line 10 of each page (Line 10 of each page is the invoice's page #), I need to insert some text on line 1 (which will be used as a delimiter to split the file). Invoices can have multiple pages but the " 1" (70 spaces followed by "1") indicates that this is a new invoice.
When " 1" (70 spaces followed by "1") is encountered, I want to insert some text on the blank line that is 9 lines above it (which is the first line of this invoice). Do this for every every occurrence in the file. Then I can break the file apart into a separate file for each invoice.
I know I can use sed to insert data immediately before the pattern but how can I insert data 9 lines above it?
I can usually get it done with sed & awk but this one is stumping me.