# 查看第一行日志的字段分布
head -1 access.log | awk '{for(i=1;i<=NF;i++) print i": "$i}'
# 或者统计各字段类型
head -1000 access.log | awk '{print $10}' | sort -n | tail -5
# 查询响应体大于指定大小
awk '$10 > 1048576' access.log > large_requests.log
# 查询特定路径的请求记录
awk '$7 ~ /^\/api\/path1\/path2/ {print}' access.log > apas_requests.log
#去重请求地址
awk '{print $7}' access.log | sort -u > unique_paths.txt
# 如果需要知道每个路径的访问次数
awk '{print $7}' access.log | sort | uniq -c | sort -nr > paths_with_count.txt
# 只保留出现次数大于等于2的记录
awk '{print $7}' access.log | sort | uniq -c | sort -nr | awk '$1 >= 4' > paths_with_count.txt
# 过滤出带有字符串
awk '{print $7}' access.log | sort | uniq -c | sort -nr | awk '$1 > 1 && $0 ~ /api/' > paths_with_count.txt
# 过滤出不带有字符串
awk '{print $7}' access.log | sort | uniq -c | sort -nr | awk '$1 > 1 && $0 !~ /api/' > paths_with_count.txt