How to UNIX sort by one column only?
- by ssn
I know that the -k option for the Unix sort allow us to sort by a specific column and all of the following. For instance, given the input file:
2 3
2 2
1 2
2 1
1 1
Using sort -n -k 1, I get an output sorted by the 1st column and then by the 2nd:
1 1
1 2
2 1
2 2
2 3
However, I want to keep the 2nd column ordering, like this:
1 2
1 1
2 3
2 2
2…