Sort logs by date field in bash

后端 未结 4 1972
我寻月下人不归
我寻月下人不归 2020-12-05 04:43

let\'s have

126 Mar  8 07:45:09 nod1 /sbin/ccccilio[12712]: INFO: sadasdasdas
  2 Mar  9 08:16:22 nod1 /sbin/zzzzo[12712]: sadsdasdas
  1 Mar  8 17:20:01 no         


        
4条回答
  •  不知归路
    2020-12-05 05:18

    For GNU sort: sort -k2M -k3n -k4

    • -k2M sorts by second column by month (this way "March" comes before "April")
    • -k3n sorts by third column in numeric mode (so that " 9" comes before "10")
    • -k4 sorts by the fourth column.

    See more details in the manual.

提交回复
热议问题