V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
daijinming
V2EX  ›  程序员

1G 的 Nginx 日志如何过滤去包含某个路径的记录行

  •  
  •   daijinming · Dec 22, 2021 · 2445 views
    This topic created in 1590 days ago, the information mentioned may be changed or developed.

    这里由于一直没有做 nginx 日志切割,结果文件滚到 1G 多,不过压缩后也就 40 多 M ,不知道有没有办法可以过滤出其中包含某个路径的记录行,应该不会太多

    5 replies    2021-12-22 22:25:14 +08:00
    ThirdFlame
        1
    ThirdFlame  
       Dec 22, 2021
    grep
    pgrep
    cheng6563
        2
    cheng6563  
       Dec 22, 2021   ❤️ 3
    cat nginx.log | grep '/XXXX/YYYY' > new.log
    daijinming
        3
    daijinming  
    OP
       Dec 22, 2021
    @cheng6563 简单又实用
    leoleoasd
        4
    leoleoasd  
       Dec 22, 2021
    > cat nginx.log | grep '/XXXX/YYYY' > new.log

    更简单的写法:grep '/xxxx/yyy' nginx.log > new.log
    yinyu
        5
    yinyu  
       Dec 22, 2021
    会上 V 站不会上 Google 吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4429 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 09:46 · PVG 17:46 · LAX 02:46 · JFK 05:46
    ♥ Do have faith in what you're doing.