I need to extract "tables" from big log files. A table is delimited by a line that contains:
IMPRESSION DE LA TABLE TSTR
and by the 4th occurrence of this line:
--------- ---------------------------------------------------------------
I cannot find a more precise definition of my table.
As an example, my log file contains:
SOME
TEXT
BEFORE
IMPRESSION DE LA TABLE TSTR 1323
--------- ---------------------------------------------------------------
POSITION | INDICE | ARGUMENT
--------- ---------------------------------------------------------------
| TYPE | VALEUR | TYPE | VALEUR
--------- ---------------------------------------------------------------
1 | CHAINE | COMPTEUR1 | ENTIER | 0
2 | CHAINE | COMPTEUR2 | ENTIER | 0
3 | CHAINE | RHO_1 | TABLE | 5187
4 | CHAINE | RHO_2 | TABLE | 6029
--------- ---------------------------------------------------------------
ANY
OTHER
TEXT
FOLLOWS
And I would like to get:
IMPRESSION DE LA TABLE TSTR 1323
--------- ---------------------------------------------------------------
POSITION | INDICE | ARGUMENT
--------- ---------------------------------------------------------------
| TYPE | VALEUR | TYPE | VALEUR
--------- ---------------------------------------------------------------
1 | CHAINE | COMPTEUR1 | ENTIER | 0
2 | CHAINE | COMPTEUR2 | ENTIER | 0
3 | CHAINE | RHO_1 | TABLE | 5187
4 | CHAINE | RHO_2 | TABLE | 6029
--------- ---------------------------------------------------------------
I found ideas at:
How to select lines between two patterns?
Extract lines between two patterns from a file
But none of them allows for finding the n-th occurrence of a pattern.
Note also that I have other tables in my file (with other names), that I don't want to extract.