url_summary() { awk ‘{print $7}’ nginx.log | sed -E ‘s@/[0-9]+@/int@g;s/[a-zA-Z0-9-]+.jpg/id.jpg/g;s/[a-zA-Z0-9-]+.png/id.png/g;s/[a-zA-Z0-9-]+.gif/id.gif/g’ | sort | uniq -c | sort -nr | head -20; }
url_summary(){ awk '{print $7}' nginx.log | sed -e 's#/topics/[0-9]\+#/topics/int#g' | sed -e 's#/replies/[0-9]\+#/replies/int#g' | sed -E 's/[a-zA-Z0-9-]+.(png|jpg)/id.png/g' |sort |uniq -c | sort -nr | head -20;}
#张琴作业
url_summary() {
awk '{print $7}' nginx.log | sed -E 's@/[0-9]+@/int@g;s/[a-zA-Z0-9-]+.jpg/id.jpg/g;s/[a-zA-Z0-9-]+.png/id.png/g;s/[a-zA-Z0-9-]+.gif/id.gif/g' | sort | uniq -c | sort -nr | head -20;
}
实现代码:
url_summary(){ awk ‘{print $7}’ nginx.log | sed -E ‘s@/topics/[0-9]@/topics/int@ ; s@/replies/[0-9]@/replies/int@ ; s#/[a-zA-Z0-9-]+.png#/id.png# ; #/topics/[0-9]*#/topics/int#’ | sort | uniq -c | sort -nr | head -20;}
实现结果:
url_summary(){ awk ‘{print $7}’ nginx.log |sed -E ‘s#/topics/[0-9]#/topics/int#g;s#/replies/[0-9]#replies/int#g;s#([0-9a-z-]).png#int.png#g;s#([0-9a-z-]).jpg#int.jpg#’|sort|uniq -c|sort -nr|head -20 }
吕川作业
1.find_error_log() { grep -E ‘" 404|" 500’ nginx.log ; }
2.find_before(){ grep -B 2 ‘" 500’ nginx.log; }
3.find_top_3(){
grep ‘/topics/’ nginx.log |sed ‘s@/topics/[0-9]*@/topics/number@’|awk ‘{print $7}’|sort|uniq -c|sort -nr|head -3;
}
4.url_summary(){
cat nginx.log | sed -e ‘s@/topics/[0-9]/replies/[0-9]/edit@/topics/int/replies/int/edit@’ -e ‘s#/photo/2018/..png#/photo/2018/id.png#’ -e 's#"[A-Z]#url#’ -e ‘#/topics/[0-9]*#/topics/int#’|awk ‘{print $6"\t"$7}’|sort|uniq -c|sort -nr|head -20;
}
ellie(){ cat nginx.log | awk ‘{print $7}’ | sed ‘s#/topics/[0-9]/replies/[0-9]#/topics/int/replies/int#;s#/uploads/photo/[0-9]./..png#/uploads/photo/2018/id.png#;s#/topics/[0-9].*#/topics/int#’ | sort | uniq -c | sort -nr | head -20 ;}
url_summary() { awk ‘{print $7 }’ nginx.log | sed ‘s/topics/[0-9]+/topics/int/g;s/replies/[0-9]+/replies/int/g;s/(-|[0-9]|[a-z])+.png/id.png/’ | sort | uniq -c | sort -nr | head -20 }
补最后一个作业:
url_summary(){
awk -F ’ ’ ‘{print $7}’ nginx.log | sed -E ‘s@/topics/[0-9]@/topics/int@;s@replies/[0-9]/@replies/int/@;s@/[0-9a-z-].png@/id.png@;s@?\S.@@’|sort -nr|uniq -c |sort -nr|head -20
}