Performance issue with parsing large log files (~5gb) using awk, grep, sed

后端 未结 4 518
孤城傲影
孤城傲影 2021-02-06 04:47

I am currently dealing with log files with sizes approx. 5gb. I\'m quite new to parsing log files and using UNIX bash, so I\'ll try to be as precise as possible. While searchi

4条回答
  •  粉色の甜心
    2021-02-06 05:02

    If you don't know the sequence of your strings, then:

    awk '/str1/ && /str2/ && /str3/ && /str4/' filename
    

    If you know that they will appear one following another in the line:

    grep 'str1.*str2.*str3.*str4' filename
    

    (note for awk, {print} is the default action block, so it can be omitted if the condition is given)

    Dealing with files that large is going to be slow no matter how you slice it.

提交回复
热议问题