I have a text file and it requires some formatting.
I know that if you want to add a blank line above every line that matches your regexp, you can use:
sed '/regexp/{x;p;x;}'
But I'd like to add a blank line, not one line above, but two lines above the line which matches my regexp.
The pattern I'll be matching is a postal code, in the address line.
Here is (part of) the format that the file has.
dynamic line (belongs to previous business)
name of a new business
address of new business
And an example:
Languages Spoken: English
Arnold's Cove, Nfld (sub To Clarenville)
Nile Road, Arnolds Cove, NL, A0B1N0
I'd like to have the new line above the business name. Thus:
Languages Spoken: English
Arnold's Cove, Nfld (sub To Clarenville)
Nile Road, Arnolds Cove, NL, A0B1N0
Solutions in Python or Perl are good as well.