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
sorry for my ignorance, is this a perl one liner? I'm on a windows machine and it shows error like:
yes. I'm not sure how command line perl works on Windows, but you could try wrapping it all into a single command line before pasting it into the Windows console.
aaaam.. currently i'm trying it sir.. but certainly i'm missing something
thanks for your answer
this error:
Can't find string terminator '"' anywhere before EOF at -e line 1.
as I say, I don't know how command line perl works on Windows. you could try to save the code as splitter.pl and then run it
perl splitter.pl