再见青春
分类: LINUX
2020-04-24 16:22:47
整体语法:
awk '{pattern + action}' {filenames}
取日志Top 10:
awk '$7 ~ /api/ {print$7}' access.log | sort -n | uniq -c | sort -nr | head -n 10
统计404:
awk '{if($9~/404/)a[$1" "$9]++}END{for(i in a)print i,a[i]}' access.log
判断:
awk '{if (NR>=20 && NR<=30) print $1}' test.txt
三目表达式:
awk 'BEGIN{a="b";print a=="b"?"ok":"err"}'