Extract lines with min value, using two field separators.

I have a file with two ID columns followed by five columns of counts in fraction form. I'd like to print lines that have a count of at least 4 (so at least 4 in the numerator, e.g. 4/17) in at least one of the five columns.

Input file:

comp51820_c1_seq1 693 0/29 0/50 0/69 0/36 0/31
comp51820_c1_seq1 694 0/29 0/54 1/67 0/34 0/30
comp51820_c1_seq1 710 0/11 0/36 0/14 0/25 4/17
comp51820_c1_seq1 711 1/11 2/35 6/14 5/25 6/17

Desired output:

comp51820_c1_seq1 710 0/11 0/36 0/14 0/25 4/17
comp51820_c1_seq1 711 1/11 2/35 6/14 5/25 6/17

I'm still new but I'm thinking awk could help, using "/" as the field separator. But I'm not sure how to keep the spaces as field separators as well. I have been looking into split, but it's not clear (to me) it will help.

Any ideas out there? I'm not great at parsing files yet and it's quite a bottleneck in my work (which obviously is not programming)...

awk '/[4-9]\//' filename

This works for the example I gave, but would not work if the counts were 10, 11, 12, or 13. How could I specify minimum 4 rather than 4-9?

---------- Post updated at 11:33 PM ---------- Previous update was at 11:21 PM ----------

I just realized I used a bad input example--all lines had a value in the numerator of at least 4. I have changed it now so that the input and output are correct. Sorry to waste your time.

Assuming that your original condition is still true:

awk '{for(i=3; i<=NF; ++i){ split($i,f, "/"); if(f[1] > 3){ print $0; break }}}'

You could also try the slightly simpler (using both space and slash as field separators):

awk -F '[ /]' '
{       for(i = 3; i < NF; i += 2)
                if($i >= 4) {
                        print
                        next
                }
}' input

or if you insist on a 1-line solution:

awk -F'[ /]' '{for(i=3;i<NF;i+=2) if($i>=4){print;next}}' input

If there is never a / in an ID field you can as well try

egrep '([4-9]|[1-9][0-9]+)/'

And same with awk

awk '/([4-9]|[1-9][0-9]+)\//' file
comp51820_c1_seq1 710 0/11 0/36 0/14 0/25 41/17
comp51820_c1_seq1 711 1/11 2/35 6/14 5/25 6/17