{"id":150675,"date":"2019-07-12T08:39:52","date_gmt":"2019-07-12T00:39:52","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=150675"},"modified":"2019-07-04T11:56:44","modified_gmt":"2019-07-04T03:56:44","slug":"shell-sort-ip","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/shell-sort-ip.html","title":{"rendered":"\u6848\u4f8b\u4e09\uff1ashell\u7edf\u8ba1ip\u8bbf\u95ee\u60c5\u51b5\u5e76\u5206\u6790\u8bbf\u95ee\u65e5\u5fd7"},"content":{"rendered":"
\u9898\u76ee\u8981\u6c42<\/strong><\/div>\n

\u6709\u65e5\u5fd7 1.log\uff0c\u90e8\u5206\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n

\r\n112.111.12.248 \u2013 [25\/Sep\/2013:16:08:31 +0800]formula-x.haotui.com\u201c\/seccode.php?update=0.5593110133088248\u2033 200\u2033http:\/\/formula\ufffdx.haotui.com\/registerbbs.php\u201d \u201cMozilla\/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1;)\u201d61.147.76.51 \u2013 [25\/Sep\/2013:16:08:31 +0800]xyzdiy.5d6d.com\u201c\/attachment.php?aid=4554&k=9ce51e2c376bc861603c7689d97c04a1&t=1334564048&fid=9&sid=zgohwYoLZq2qPW233ZIRsJiUeu22XqE8f49jY9mouRSoE71\u2033301\u2033http:\/\/xyzdiy.5d6d.com\/thread-1435-1-23.html\u201d \u201cMozilla\/4.0 (compatible; MSIE 6.0;Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)\u201d\r\n<\/pre>\n

\u7edf\u8ba1\u51fa\u6bcf\u4e2a IP \u7684\u8bbf\u95ee\u91cf\u6709\u591a\u5c11<\/p>\n

\u4e60\u9898\u5206\u6790<\/strong><\/div>\n

\u8fd9\u79cd\u5206\u6790\u65e5\u5fd7\u7684\u9700\u6c42\uff0c\u5728\u5e73\u65f6\u5de5\u4f5c\u4e2d\u5f88\u5e38\u89c1\uff0c\u800c\u4e14\u627e\u8fd0\u7ef4\u5de5\u4f5c\u65f6\u7684\u7b14\u8bd5\u9898\u91cc\u9762\u51fa\u73b0\u9891\u7387\u4e5f\u975e\u5e38\u591a\u3002<\/p>\n

\u6839\u636e\u65e5\u5fd7\u5185\u5bb9\uff0c\u53ef\u4ee5\u770b\u5230 IP \u5730\u5740\u5c31\u662f\u7b2c\u4e00\u6bb5\u5185\u5bb9\uff0c\u6240\u4ee5\u53ea\u9700\u8981\u628a 1.log \u7684\u7b2c\u4e00\u6bb5\u7ed9\u8fc7\u6ee4\u51fa\u6765\uff0c\u7136\u540e\u8fd1\u4e00\u6b65\u7edf\u8ba1\u6bcf\u4e00\u4e2a IP \u7684\u91cf\u5373\u53ef\u3002<\/p>\n

\u8fc7\u6ee4\u7b2c\u4e00\u6bb5\uff0c\u4f7f\u7528 awk \u5c31\u53ef\u4ee5\u5f88\u5bb9\u6613\u5f97\u5230\uff0c\u800c\u7edf\u8ba1\u6bcf\u4e2a IP \u7684\u8bbf\u95ee\u91cf\u5219\u9700\u8981\u6392\u5e8f\u7136\u540e\u518d\u8ba1\u7b97\u6570\u91cf\uff0c<\/p>\n

\u6392\u5e8f\u4f7f\u7528 sort \u547d\u4ee4\uff0c\u7edf\u8ba1\u6bcf\u4e2a IP \u8bbf\u95ee\u91cf\u7528 uniq\u3002<\/p>\n

\u4e60\u9898\u7b54\u6848<\/strong><\/div>\n
\r\nawk '{print $1}' 1.log |sort -n |uniq -c |sort -n\r\n<\/pre>\n
\u7b54\u6848\u89e3\u6790<\/strong><\/div>\n
\r\n1. awk \u547d\u4ee4\u5728\u5206\u6bb5\u65b9\u9762\u8fd8\u662f\u6bd4\u8f83\u6709\u4f18\u52bf\u7684\uff0c\u8fd9\u91cc\u7684{print $1}\u8bb2\u7b2c\u4e00\u6bb5\u6253\u5370\u51fa\u6765\uff0cawk \u53ef\u4ee5\u7528-F \u6307\u5b9a\u5206\u9694\u7b26\uff0c\u5982\u679c\u4e0d\u6307\u5b9a\u5206\u9694\u7b26\uff0c\u9ed8\u8ba4\u5c31\u4ee5\u7a7a\u767d\u5b57\u7b26(\u6bd4\u5982\u7a7a\u683c\u3001Tab \u7b49)\uff0c\u672c\u9898\u4e2d\uff0cIP \u5730\u5740\u5c31\u662f\u5728\u7b2c\u4e00\u6bb5\u3002\r\n\r\n2. sort \u547d\u4ee4\u662f\u6392\u5e8f\u7684\u547d\u4ee4\uff0c-n \u9009\u9879\u8868\u793a\u4ee5\u6570\u5b57\u7684\u5f62\u5f0f\u6392\u5e8f\uff0c\u5982\u679c\u4e0d\u52a0-n\uff0c\u5219\u4ee5 ASCII \u6392\u5e8f\uff0c\u672c\u9898\u4e2d\u7684 IP \u5730\u5740\u4ee5\u6570\u5b57\u7684\u5f62\u5f0f\u6392\u5e8f\u66f4\u5bb9\u6613\u533a\u5206\u3002\r\n\r\n3. uniq \u547d\u4ee4\u662f\u7528\u6765\u53bb\u91cd\u590d\u7684\uff0c\u4e00\u4e2a\u6587\u672c\u4e2d\u5982\u679c\u6709\u591a\u884c\u5185\u5bb9\u662f\u4e00\u6a21\u4e00\u6837\u7684\uff0c\u4f7f\u7528 uniq \u547d\u4ee4\u5c31\u53ef\u4ee5\u628a\u76f8\u540c\u5185\u5bb9\u7684\u884c\u7ed9\u5220\u9664\u6389\uff0c\u53ea\u7559\u4e00\u884c\u3002\u800c-c \u9009\u9879\u7684\u4f5c\u7528\u662f\u8ba1\u7b97\u91cd\u590d\u7684\u884c\u6570\uff0c\u6240\u4ee5\u5728\u6b64\u9898\u4e2d\u4f7f\u7528 uniq -c \u6b63\u597d\u53ef\u4ee5\u8ba1\u7b97 IP \u5730\u5740\u7684\u8bbf\u95ee\u6570\u91cf\u3002\u4e0d\u8fc7\uff0c\u5927\u5bb6\u4e00\u5b9a\u8981\u6ce8\u610f\uff0cuniq \u53bb\u91cd\u7684\u524d\u63d0\u662f\u9996\u5148\u8981\u6392\u5e8f\u3002\r\n\r\n4. \u672c\u9898\u7b54\u6848\u91cc\u6700\u540e\u6ca1\u5f97 sort -n \u610f\u601d\u662f\u6309\u8bbf\u95ee\u91cf\u5927\u5c0f\u6765\u6392\u5e8f\uff0c\u8bf7\u6c42\u91cf\u8d8a\u5927\u7684 IP \u6392\u5728\u8d8a\u540e\u9762\uff0c\u5982\u679c\u8981\u60f3\u6392\u5728\u524d\u9762\uff0c\u53ef\u4ee5\u52a0\u4e00\u4e2a-r \u9009\u9879\uff0c\u5373 sort \u2013nr\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u6709\u65e5\u5fd7 1.log\uff0c\u90e8\u5206\u5185\u5bb9\u5982\u4e0b\uff1a 112.111.12.248 \u2013 [25\/Sep\/2013:16:08:3 […]<\/p>\n","protected":false},"author":668,"featured_media":100371,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-150675","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/150675","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/668"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=150675"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/150675\/revisions"}],"predecessor-version":[{"id":150758,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/150675\/revisions\/150758"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/100371"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=150675"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=150675"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=150675"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}