stable sort in linux

前端 未结 2 1894
孤独总比滥情好
孤独总比滥情好 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:18

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

    sort -k1,1 -s t.txt
    

提交回复
热议问题