Linux shell sort file according to the second column?

后端 未结 4 1578
囚心锁ツ
囚心锁ツ 2020-12-02 17:54

I have a file like this:

FirstName, FamilyName, Address, PhoneNumber

How can I sort it by FamilyName?

4条回答
  •  青春惊慌失措
    2020-12-02 18:36

    To sort by second field only (thus where second fields match, those lines with matches remain in the order they are in the original without sorting on other fields) :

    sort -k 2,2 -s orig_file > sorted_file
    

提交回复
热议问题