Sum values in a row and compare the results to a value with awk or sed

Sum values in a row and compare the results to a value with awk or sed

0

I have a file organized as below

ERR1017187.315 32630:2 0:37 32630:7 0:71 |:| 0:25 32630:10 0:82
ERR1017187.333 32630:2 0:37 32630:3 0:75 |:| 0:117
ERR1017187.336 32630:1 0:37 32630:6 0:73 |:| 0:117
ERR1017187.358 32630:3 0:35 32630:2 0:77 |:| 0:117

Basically, i need, for every row, to sum the X in “32630:X” and if the sum is above 20 keep the row.
For instance, for the first row would be 2+7+10=27, i keep the row

Second 2+3=5, discard the row

How can i achieve that using awk or sed?


awk


kraken


sed

• 20 views

2 hours ago by


M

0

Read more here: Source link