Hi all,
I am now learning awk but get stuck on the following problem.
I have a file (input.txt) with various numerical ranges (before it, there is an id and :) in each line such as:
NP_416485.4: 4-5, 113-114, 395-399, 657-666, 671-675, 844-880, 889-889, 891-895, 963-966, 970-970, 991-992, 1126-1235
NP_417679.2: 309-413, 418-421, 441-442, 444-445, 447-481, 939-941, 943-984
NP_418770.2: 264-265, 267-272, 276-277, 287-288
NP_415931.4: 32-33, 73-75, 387-388, 394-396, 531-634
Now I want to go though each id and print only those ranges which are >=30. For the above input, the output should be:
NP_417679.2: 309-413, 447-481, 943-984
NP_415931.4: 531-634
I have tried this awk script:
awk -F"-" "{if(($2-$1)>=30) print $_}" input.txt
But it prints all the input ranges. Please suggest.
ps. I can also use any perl alternative