Thanks in advance for any advice.
I'm trying to sort a file by tab-delimited fields (as shown below). The important fields are fields 1 and 2.
ID (sorted by string values) and then the starting position in a larger string (sorted numerically).
KI270036.1 5137 5523 -1
KI270036.1 5215 5636 -1
**KI270036.1 546 1448 -1**
KI270036.1 6364 7425 -1
KI270036.1 8687 9529 -1
KI270041.1 1957 2343 1
KI270041.1 3114 3423 1
KI270041.1 4792 5439 1
KI270041.1 5703 6308 1
This is an example of the table I'm trying to sort. Notice that the first fields are in order as desired, but the bolded field is out of order according to my specifications.
The command I entered was:
sort -g -t ' ' -k 1,2 my_file.txt
How can I alter this to achieve the records grouped by ID and then sorted numerically by the second field?
The output I'm looking for in this example is:
**KI270036.1 546 1448 -1**
KI270036.1 5137 5523 -1
KI270036.1 5215 5636 -1
KI270036.1 6364 7425 -1
KI270036.1 8687 9529 -1
KI270041.1 1957 2343 1
KI270041.1 3114 3423 1
KI270041.1 4792 5439 1
KI270041.1 5703 6308 1
KI270036.1etc as field 1 and the column starting with5137as field 2?cutandawk