Common shell usage

Analyze nginx access logs

awk '{a[b[$1]++]}END{for(i=length(a);i>0;i--)for(j in b)if(b[j]==i){c++;if(c<=10)print j,i}}' www.dwhd.org_nginx.log

The effect is as follows

Sort statistics in reverse order

cat access.log| sort | uniq -c| sort -k 1 -n -r 
uniq can only deduplicate the adjacent two lines, so sort it first,
sort -k 1 specifies to sort by the value of the first column
-n Sort by number size
-r: sort in reverse order;

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325297431&siteId=291194637