How to sort a file in unix both alphabetically and numerically on different fields?

后端 未结 2 1610
有刺的猬
有刺的猬 2021-02-01 02:26

Please don\'t think this is a repeat of the \"Sorting alphanumeric data in unix\" question... I looked at the other answers, and think my case is a bit different!

I have

2条回答
  •  盖世英雄少女心
    2021-02-01 02:59

    Try using like this:-

    sort -k1,1 -k4,4n
    
    • -n : Makes the program sort according to numerical value
    • -k opts: Sort data / fields using the given column number. For example, the option -k 2 made the program sort using the second
      column of data. The option -k 3,3n -k 4,4n sorts each column. First
      it will sort 3rd column and then 4th column.

提交回复
热议问题