How to (numerically) sort a specific column in a text file, without affecting other columns (irrespective of whether they are sorted or unsorted)? On other threads I found -s
argument, but it does sort other columns.
Observation
$ cat tmp.txt
1 1
2 3
5 4
1 3
$ sort -s -n -k1,1 tmp.txt
1 1
1 3
2 3
5 4
Best Answer
As mentioned in the comments, you can't achieve what you want using
sort
alone.You could
cut
the input file, feed relevant part tosort
, andpaste
those.