I’m trying to sort the following file:
a 2
b 1
a 10
I need to get:
a 2
a 10
b 1
I know about the -kPOS[opts] option, and try to use it:
sort -k1 -k2n file
but this command gives me only:
a 10
a 2
b 1
So it sorts by the first column, but no by the second. Running just sort -k2n file sorts by the second column.
b 1
a 2
a 10
How could I sort it by two columns?
Edit:
sort (GNU coreutils) 5.93
You have to terminate the primary key, otherwise, sort uses all the fields starting from the given one: