How to grab the value of field before the line reached

Hi.

I have a qury whihc I hope someone could clarify.

I have a file:-

Num Measure
108 0.05
12 0.45
13 0.2
19 0.5

I wanted to grep the value of 19 from Column Num which will then take the minimum value of measure (not including 19's measure value). Means in this case, i am hoping to get 0.05 as the mininum of (0.05,0.45 and 0.2) right before the entry 19. Anyone could advise me on this?

Thanks and appreciate alot.

Please provide us with a sample output and make it clear..

Regards,
aajan

Hi

Means I have a file called test.txt

with:-
Num Measure
108 0.05
12 0.45
13 0.2
19 0.5

And in my bash I will grep a random number which match the Num column in test.txt. (e.g getting random number of Num value of 2,4,6,8,10,12) from test.txt. In test.txt, the element 12 of Num matches with the random number which I wanted to retrieve.This step i think should be find by grep command.

Next, I would like to find the minimum of measure before the element num 12 and measure 0.45 line. In this case, the output would be 0.05 since only one element is there ebfore the Num 12 and measure 0.45.

Another example; let say my random number to retrieve is 19 of test.txt. I I wanted to find the elements of Measure which gives the minimum value.

In this example; the possible value to be minimum (not including the measure which belongs to random number) are:-
0.05,0.45,0.2
Final output would be 0.05 since its the minimum among these 3 values.

Hope i dont confused you. Feel free to let me know if youre still unsure. Thanks.

Write an awk script which remembers the lowest value so far and stops when it sees the desired key. The keys would be $1 and values would be $2.