Reputation: 8927
I have a file
ksh$ cat test
b d
b c
a b
a a
I want to sort on first field but I want stable sort i.e. order of 2nd field should remain the same. I want output as:
a b
a a
b d
b c
If I try:
ksh$sort -k1 -s test
I get
a a
a b
b c
b d
Please help,
Thanks
Upvotes: 18
Views: 8627
Reputation: 799110
You forgot to constrain the key fields. By default it uses until the end of the line.
sort -k1,1 -s t.txt
Upvotes: 31