Print smallest negative number with corresponding index from a column

considering the following table:

ID          col1            col2                 col3               col4
1    -16.06801249     13.49785832   -56.57087607      -27.00500526
2     -1.53315720      0.71731735    -42.03602078      -39.78554623
3     -1.53315190      0.71731587    -42.03601548      -39.78554771
4     -1.53316243      0.8731724    -42.53602760        -39.85545910 
5     -16.  6533188    13.7606723    -42.03605186      -27.06753555

how to print (using sed or awk or ...): the smallest negative number from col4 that has value less than 1.0 in col2 (like 0.71731735, 0.8731724, etc but not 13.49785832 or 13.7606723)
expected result looks like:

ID          col2                    col4                 
2           0.71731735         -39.78554623  

I appreciate for any idea :wink:
Birda

Hi what have you tried so far? Where are you stuck?

Hi, I tried

awk 'NR == 1 || $4 < min {line = $0; min = $4}END{print line}' xample1.awk

or

sort -nk 4 xample1.awk | head -n 1

but I have problem how to consider for the 2nd column for values containing <1.0. only values containing 0.* in col2 should be considered while comparing the smallest values in col4.

what about using sed?
thank you

How about combining it with the other test:

awk '$3<1 && $5<m { m=$5; s=$1 OFS $3 OFS $5 } END{ print s }' file

(BTW, col4 = $5)