using awk remove filtered group

Viewed 59

i have an input

1   a   0,9
1   b   0,8
1   c   0,1
2   d   0,5
3   e   0,1
3   f   0,7
4   g   0,4
4   h   0,3
4   i   0,2
4   j   0,1

using awk i want to remove filtered group if third column is greater than 0.6 i want to remove other rows which first columns equal.

Desired Output:

2   d   0,5
4   g   0,4
4   h   0,3
4   i   0,2
4   j   0,1

I have used this, but this dont delete other rows.

awk  '($3 < 0.6)'  file
1 Answers

With your shown samples, could you please try following.

awk '
FNR==NR{
  temp=$3
  sub(/,/,".",temp)
  if(temp>0.6){
    noCount[$1]
  }
  next
}
!($1 in noCount)
'  Input_file  Input_file

Output will be as follows.

2   d   0,5
4   g   0,4
4   h   0,3
4   i   0,2
4   j   0,1

Explanation: Adding detailed explanation for above.

awk '                        ##Starting awk program from here.
FNR==NR{                     ##This condition will be TRUE when first time is being read.
  temp=$3                    ##Creating temp with 3rd field value here.
  sub(/,/,".",temp)          ##Substituting comma with dot in temp here.
  if(temp>0.6){              ##Checking condition if temp is greater than 0.6 then do following.
    noCount[$1]              ##Creating noCount with index of 1st field.
  }
  next                       ##next will skip all further statements from here.
}
!($1 in noCount)             ##If 1st field is NOT present in noCount then print line.
'  Input_file  Input_file    ##Mentioning Input_file names here.
Related