I have an input text file with paragraphs in it, which are separated by 3 empty lines. Example:
P1
P1
empty line here
empty line here
empty line here
P2
P2
empty line here
empty line here
empty line here
P3
P3
empty line here
empty line here
empty line here
Currently I'm using this code written into a *.awk file to get the paragraphs:
BEGIN{ORS=RS="\n\n\n"}
/some text pattern comes here because I dont want to print every paragraph just some of them but in reversed order/
So I'd like the output file to look like this:
P3
P3
empty line here
empty line here
empty line here
P2
P2
empty line here
empty line here
empty line here
P1
P1
empty line here
empty line here
empty line here
So I was wondering if I could print each paragraph to the top of the output file to get the reversed order. Is it possible to do it?