How can I sort an Apache log file by date?

后端 未结 3 427
栀梦
栀梦 2021-02-01 20:17

I have a a couple of Apache log files that have been appended together and I need to sort them by date. They\'re in the following format:

\"www.company.com\" 19         


        
3条回答
  •  长发绾君心
    2021-02-01 21:04

    This is almost too trivial to point out, but just in case it confuses anyone: grm's answer should technically be using field #3, not 4, to match the questioner's exact log format. That is, it should read:

        sort -t ' ' -k 3.9,3.12n -k 3.5,3.7M ...
    

    His answer is correct in every other respect, and can be used as-is for the common log format.

提交回复
热议问题