stable sort in linux

前端 未结 2 1883
孤独总比滥情好
孤独总比滥情好 2020-12-31 05:46

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

相关标签:
2条回答
  • 2020-12-31 06:02

    You must specify the end field:

    sort -k1,1 -s test
    
    0 讨论(0)
  • 2020-12-31 06:18

    You forgot to constrain the key fields. By default it uses until the end of the line.

    sort -k1,1 -s t.txt
    
    0 讨论(0)
提交回复
热议问题