I am currently facing a challenging script where I need to grep for the following 700e10 for example under the column partnum and find/grep for "rstcb" above that line. The problem is that it is not a fixed number of lines above the grep for "rstcb".
rstcb 700000036d048e8 tid 19150545
isfd op_mode op_flags partnum ucnt ocnt lk ra partp ocnt ucnt
0 400 297 700da0 2 2 1 700000023b8c028 715 715
1 2 3 700da0 2 2 0 700000023b8c028 715 715
2 1000400 403 700e10 1 0 0 70000002c768738 0 604
3 1000400 403 700e11 1 0 0 70000002c89a028 0 302
4 1000400 3 70051e 1 1 0 7000000242a1028 318 698
5 1000440 3 70051f 1 1 0 7000000242a15c8 318 396
Steps to get this
Step 1:
Select hex(partnum) from systables where tabname = "stocks"
Output for example:
0x00700e10
Step 2: (informix)
Run onstat -g opn | grep -i 700e10
Step 3: You will get the the above text from image for example
I would like to include a grep that can search for the text rstcb above the initial result from step 2. Once I have that I would like to awk '{print $2}'
the number 700000036d048e8