{"id":100,"date":"2014-06-24T16:32:15","date_gmt":"2014-06-24T16:32:15","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=100"},"modified":"2014-06-24T16:32:15","modified_gmt":"2014-06-24T16:32:15","slug":"%e5%8e%bb%e9%87%8d%e7%9a%84%e5%90%84%e7%a7%8d%e6%96%b9%e6%b3%95%e4%b8%8d%e5%ae%9a%e6%9c%9f%e6%9b%b4%e6%96%b0","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/100.html","title":{"rendered":"\u53bb\u91cd\u8ba1\u6570\u7684\u5404\u79cd\u65b9\u6cd5"},"content":{"rendered":"<h6>\u65b9\u6cd5\u4e00\uff08awk\uff09\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">awk '{dict[$1]++} END{for (item in dict) print dict[item]\"\\t\"item}' \/path\/to\/access.log | sort -nr &gt;ip_with_counts.txt<\/pre>\n<p>&amp;<\/p>\n<pre class=\"lang:default decode:true \">array1=$(cat \"$file\" | awk '{type[$2]+=$3} END {for (i in type) print i, type[i]}')\narray2=$(cat \"$file\" | awk '{type[\"all\"]+=$3; type[$2]+=$3} END {for (i in type) print i, type[i]}')\n\n\u8bbe\u7f6e\u4e00\u4e2a\u6570\u7ec4\uff0c\u4f46\u662f\u7528\u4e0d\u540c\u7684\u6570\u7ec4\u4e0b\u6807\u8fdb\u884c\u533a\u5206\uff08\u6bd4\u5982\u8fd9\u91cc\u7684\uff1aall \u548c $2 \uff0c\u53ea\u662f\u4e0b\u6807\u4e0d\u540c\uff0c\u4f46\u7528\u7684\u540c\u4e00\u4e2a\u6570\u7ec4\uff09\uff0c\u6700\u540e\u7528\u4e2aEND\u8fdb\u884c\u6253\u5370\u5373\u53ef\u3002<\/pre>\n<p>=<\/p>\n<h6>\u65b9\u6cd5\u4e8c\uff08PHP\uff09\uff1a<\/h6>\n<pre class=\"lang:default decode:true \">&lt;?php\n$all = file(\"email.txt\");\n$lines = array();\nfor($i=0; $i&lt;count($all); $i++) {\n    $all[$i] = trim($all[$i]);\n    if($all[$i]) {\n        $lines[$all[$i]] = $i; #\u601d\u60f3\uff1a\u7528Email\u5730\u5740\u6765\u4f5c\u4e3a\u6570\u7ec4\u4e0b\u6807\uff0c\u884c\u6570\u4e3a\u5bf9\u5e94\u7684\u6570\u7ec4\u5143\u7d20\u7684\u503c\n    }\n}\n\n\/\/ $temp = array_keys($lines);\n\/\/ natsort($temp);\t#\u81ea\u7136\u6392\u5e8f\n\/\/ print_r($temp);<\/pre>\n<p>=<\/p>\n<h6>\u65b9\u6cd5\u4e09\uff08Python\uff09\uff1a<\/h6>\n<pre class=\"lang:default decode:true  \">f = open('email.txt', 'r')\ndic = {}\ni = 1\nwhile True:\n\tline = f.readline().strip()\n\tif len(line) != 0:\n\t\tdic[line] = i\n\t\ti + =1\nf.close()\n\nprint(dic['xxx@163.com']) #\u6253\u5370\u51fa\u9700\u8981\u67e5\u627e\u7684Email\u5730\u5740\u7684\u4f4d\u7f6e(\u4ece1\u5f00\u59cb\u8ba1\u7b97)<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u65b9\u6cd5\u4e00\uff08awk\uff09\uff1a awk &#8216;{dict[$1]++} END{for (item in dict) prin [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,12],"tags":[74,48,8],"class_list":["post-100","post","type-post","status-publish","format-standard","hentry","category-programing","category-tools","tag-awk","tag-php","tag-python"],"views":5482,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}