Hi everybody.
I have being trying to solve this with awk but there is always something
missing. I have one file like this :
CONFIGURATION : 1
a b c 2.5
aa b1 c1 1.3
a2 b2 c2 4.9
...
aN bN cN 8.7
CONFIGURATION : 2
z d g 4.2
aa d1 g1 12.3
z2 d2 g2 4.
...
zN dN gN 6.4
CONFIGURATION : 3
t e h 54.
CONFIGURATION : 4
CONFIGURATION : 5
...
...
CONFIGURATION : M
w y i 0.
aa y1 i1 1.
w2 y2 i2 4.2
...
wN yN iN 2.4
As you can see, between the lines containing the word CONFIGURATION
there is a number of lines (0 to N), each of them contains 4 columns.
What I need to do is quite simple but painful without a good script.
For each configuration, I must look for the word "aa". When I have
a hit, I must print the third and fourth columns and the configuration number.
I know how to do this with awk. The problem is when I do NOT have
hit. In the lines above, configurations 4 and 5 shows nothing.
I could not figure out how to build a logic flag yet.
Therefore, the output for the example above should be :
(configuration) (third column) (fourth column)
1 c1 1.3
2 g1 12.3
3 0 0
4 0 0
5 0 0
...
M i1 1.
I appreciate any help !
Thanks,
Serg