//正常的過濾
[root@localhost tjm]# cat access.log | cut -d " " -f 1 | sort | uniq -c | sort -nr | head -n 10 33 172.68.133.11 30 172.69.22.69 27 172.68.142.144 27 162.158.255.87 26 172.68.141.221 26 162.158.255.213 25 172.68.189.164 25 172.68.141.203 25 162.158.255.11 24 172.68.141.167
//使用awk過濾
[root@localhost tjm]# cat access.log | awk -F ' ' '{print $1}' | sort | uniq -c | sort -nr | head -n 10 33 172.68.133.11 30 172.69.22.69 27 172.68.142.144 27 162.158.255.87 26 172.68.141.221 26 162.158.255.213 25 172.68.189.164 25 172.68.141.203 25 162.158.255.11 24 172.68.141.167
//加上>1.txt && cat 1.txt -n 顯示前十IP的同時,使用cat -n 在前面顯示第幾行
[root@localhost tjm]# cat access.log | cut -d " " -f 1 | sort | uniq -c | sort -nr | head -n 10 > 1.txt && cat 1.txt -n 1 33 172.68.133.11 2 30 172.69.22.69 3 27 172.68.142.144 4 27 162.158.255.87 5 26 172.68.141.221 6 26 162.158.255.213 7 25 172.68.189.164 8 25 172.68.141.203 9 25 162.158.255.11 10 24 172.68.141.167