Skip to main content
8 events
when toggle format what by license comment
Aug 7, 2017 at 7:24 comment added RomanPerekhrest @DavidFoerster, read my notation in the answer
Aug 7, 2017 at 7:23 history edited RomanPerekhrest CC BY-SA 3.0
added 110 characters in body
Aug 7, 2017 at 7:07 comment added David Foerster I’m not sure why one would need to sort at all. There’s no such requirement in the question.
Aug 7, 2017 at 5:28 comment added RomanPerekhrest @cas, I've wrote the solution for potentially unsorted input file, so sorting should be made beforehand
Aug 7, 2017 at 2:31 comment added cas OTOH, if the file is huge, it would be better to sort awk's output rather than awk's input.
Aug 7, 2017 at 2:22 comment added cas +1. Also, if the file is huge, it's worthwhile avoiding unnecessary processing of it. If the file is sorted with sort -k1,1V -k2,2n (note the V version sort on field 1, requires GNU sort), then $1 > "chr4" {exit}; can be added to the start of the awk script to exit immediately after all chr4 lines have been processed. without GNU sort (but input is still sorted), you'd need to use a flag variable to exit early after the chr4 lines: e.g. awk '$1 != "chr4" && found {exit} ; $1=="chr4" && $2>=3 && $2<=7 {print ; found=1}'
Aug 6, 2017 at 20:00 vote accept cooldood3490
Aug 6, 2017 at 19:48 history answered RomanPerekhrest CC BY-SA 3.0