I have a 25-line file that looks like:
cat -n oz
1 PARSING IN CURSOR #140499 dep=0 tim=4217919222030 sqlid='ftf4q8xj38z7k'
2 WAIT #1404991: nam='SQL*Net message' ela= 1 tim=4217919224736
3 WAIT #1404991: nam='SQL*Net message' ela= 655 tim=4217919225409
4 PARSING IN CURSOR #140499 dep=0 tim=4217919225606 sqlid='9fufagwmu041b'
5 WAIT #1404991: nam='SQL*Net message' ela= 1 tim=4217919225677
6 WAIT #1404991: nam='SQL*Net message' ela= 736 tim=4217919226432
7 PARSING IN CURSOR #140499 dep=0 tim=4217919226577 sqlid='bzdm0nbr7c036'
8 WAIT #1404990: nam='SQL*Net message' ela= 1 tim=4217919226665
9 WAIT #1404990: nam='SQL*Net message' ela= 2027 tim=4217919228710
10 WAIT #1404991: nam='SQL*Net message' ela= 1 tim=4217919228849
11 PARSING IN CURSOR #140499 dep=1 tim=4217919225606 sqlid='9fufagwmu041b'
12 WAIT #1404991: nam='SQL*Net message' ela= 603 tim=4217919229470
13 WAIT #1404991: nam='SQL*Net message' ela= 1 tim=4217919229647
14 WAIT #1404991: nam='SQL*Net message' ela= 521 tim=4217919230185
15 WAIT #1404991: nam='SQL*Net message' ela= 0 tim=4217919230330
16 WAIT #1404991: nam='SQL*Net message' ela= 758 tim=4217919231107
17 WAIT #1404990: nam='SQL*Net message' ela= 0 tim=4217919231222
18 WAIT #1404990: nam='SQL*Net message' ela= 1635 tim=4217919232874
19 PARSING IN CURSOR #140499 dep=0 tim=4217919226577 sqlid='bzdm0nbr7c036'
20 WAIT #1404990: nam='SQL*Net message' ela= 1 tim=4217919226665
21 WAIT #1404990: nam='SQL*Net message' ela= 2027 tim=4217919228710
22 PARSING IN CURSOR #140499 dep=1 tim=4217919225606 sqlid='9fufagwmu041b'
23 WAIT #1404991: nam='SQL*Net message' ela= 521 tim=4217919230185
24 WAIT #1404991: nam='SQL*Net message' ela= 0 tim=4217919230330
25 WAIT #1404991: nam='SQL*Net message' ela= 758 tim=4217919231107
that I want to transform into ("cat -n" of same file once processed):
1 PARSING IN CURSOR #140499 dep=0 tim=4217919222030 sqlid='ftf4q8xj38z7k'
2 WAIT #1404991: nam='SQL*Net message' ela= 1 tim=4217919224736
3 WAIT #1404991: nam='SQL*Net message' ela= 655 tim=4217919225409
4 PARSING IN CURSOR #140499 dep=0 tim=4217919225606 sqlid='9fufagwmu041b'
5 WAIT #1404991: nam='SQL*Net message' ela= 1 tim=4217919225677
6 WAIT #1404991: nam='SQL*Net message' ela= 736 tim=4217919226432
7 PARSING IN CURSOR #140499 dep=0 tim=4217919226577 sqlid='bzdm0nbr7c036'
8 WAIT #1404990: nam='SQL*Net message' ela= 1 tim=4217919226665
9 WAIT #1404990: nam='SQL*Net message' ela= 2027 tim=4217919228710
10 WAIT #1404991: nam='SQL*Net message' ela= 1 tim=4217919228849
11 PARSING IN CURSOR #140499 dep=0 tim=4217919226577 sqlid='bzdm0nbr7c036'
12 WAIT #1404990: nam='SQL*Net message' ela= 1 tim=4217919226665
13 WAIT #1404990: nam='SQL*Net message' ela= 2027 tim=4217919228710
Algorithm is:
o does first line contain (will always start with "PARS...") "dep=1" ?,
o if yes, I keep reading without outputting anything till next "PARS...",
o if contains "dep=0", I display it, with those that follow, till next "PARS...",
o then same check again, ... etc.
How easily can it be done ? Using simple shell command (cat etc.) maybe ? But my file is fairly big...
Thanks a lot.
Seb
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…