Skip to content

Instantly share code, notes, and snippets.

@iflamed
Created January 31, 2024 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iflamed/d1836385442685e364cf6deeeeca9b0c to your computer and use it in GitHub Desktop.
Save iflamed/d1836385442685e364cf6deeeeca9b0c to your computer and use it in GitHub Desktop.
使用awk 分析nginx日志
awk -F\" '{print $2}' access.log | awk '{print $2}' | awk -F\? '{print $1}' | sort -n | uniq -c | sort -rn | head -n 100
@iflamed
Copy link
Author

iflamed commented Jan 31, 2024

使用 awk 把文件的每行文本进行分割,使用-F指定分隔符,注意转移。

@iflamed
Copy link
Author

iflamed commented Jan 31, 2024

分割后的 sort, uniq 等操作则是获取 top 100 的数据。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment