{"id":2822,"date":"2013-06-09T09:06:44","date_gmt":"2013-06-09T01:06:44","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=2822"},"modified":"2013-11-21T18:17:48","modified_gmt":"2013-11-21T10:17:48","slug":"linux%e5%91%bd%e4%bb%a4%e8%a1%8c%e9%87%8c%e7%9a%84%e7%91%9e%e5%a3%ab%e5%86%9b%e5%88%80","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/2822.html","title":{"rendered":"Linux\u547d\u4ee4\u884c\u91cc\u7684\u201c\u745e\u58eb\u519b\u5200\u201d"},"content":{"rendered":"<p>\u8fd9\u91cc\u8bf4\u7684\u201c\u745e\u58eb\u519b\u5200\u201d\u662f\u6307\u90a3\u4e9b\u7b80\u5355\u7684\u4e00\u53e5\u547d\u4ee4\u5c31\u80fd\u5b8c\u6210\u5176\u5b83\u9ad8\u7ea7\u8bed\u8a00\u4e00\u5927\u7247\u4ee3\u7801\u624d\u80fd\u5b8c\u6210\u7684\u5de5\u4f5c\u3002<\/p>\n<p>\u4e0b\u9762\u7684\u8fd9\u4e9b\u5185\u5bb9\u662fQuora\u7f51\u7ad9\u4e0aJoshua Levy\u7f51\u53cb\u7684\u603b\u7ed3\uff1a<\/p>\n<p>\u901a\u8fc7sort\/uniq\u83b7\u53d6\u6587\u4ef6\u5185\u5bb9\u7684\u4ea4\u96c6\u3001\u5408\u96c6\u548c\u4e0d\u540c\u4e4b\u5904\uff1a\u5047\u8bbe\u6709a\u3001b\u4e24\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u6587\u4ef6\u672c\u8eab\u5df2\u7ecf\u53bb\u9664\u4e86\u91cd\u590d\u5185\u5bb9\u3002\u4e0b\u9762\u662f\u6548\u7387\u6700\u9ad8\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5904\u7406\u4efb\u4f55\u4f53\u79ef\u7684\u6587\u4ef6\uff0c\u751a\u81f3\u51e0\u4e2aG\u7684\u6587\u4ef6\u3002(Sort\u5bf9\u5185\u5b58\u6ca1\u6709\u8981\u6c42\uff0c\u4f46\u4e5f\u8bb8\u4f60\u9700\u8981\u7528 -T \u53c2\u6570\u3002)\u53ef\u4ee5\u8bd5\u7740\u6bd4\u8f83\u4e00\u4e0b\uff0c\u4f60\u53ef\u4ee5\u770b\u770b\u5982\u679c\u7528Java\u6765\u5904\u7406\u78c1\u76d8\u4e0a\u6587\u4ef6\u7684\u5408\u5e76\uff0c\u9700\u8981\u7528\u591a\u5c11\u884c\u4ee3\u7801\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncat a b | sort | uniq &gt; c # c \u662fa\u548cb\u7684\u5408\u96c6\r\ncat a b | sort | uniq -d &gt; c # c \u662fa\u548cb\u7684\u4ea4\u96c6\r\ncat a b b | sort | uniq -u &gt; c # c \u662fa\u548cb\u7684\u4e0d\u540c\r\n<\/pre>\n<p>\u6c47\u603b\u4e00\u4e2a\u6587\u672c\u5185\u5bb9\u91cc\u7b2c\u4e09\u5217\u6570\u5b57\u7684\u548c(\u8fd9\u4e2a\u65b9\u6cd5\u8981\u6bd4\u7528Python\u6765\u505a\u5feb3\u500d\u5e76\u53ea\u97001\/3\u7684\u4ee3\u7801\u91cf)\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nawk \u2018{ x += $3 } END { print x }\u2019 myfile\r\n<\/pre>\n<p>\u5982\u679c\u4f60\u60f3\u67e5\u770b\u4e00\u4e2a\u76ee\u5f55\u6811\u91cc\u7684\u6587\u4ef6\u7684\u4f53\u79ef\u548c\u4fee\u6539\u65e5\u671f\uff0c\u7528\u4e0b\u9762\u7684\u65b9\u6cd5\uff0c\u76f8\u5f53\u4e8e\u4f60\u6328\u4e2a\u76ee\u5f55\u505a\u201dls -l\u201d\uff0c\u800c\u4e14\u8f93\u51fa\u7684\u5f62\u5f0f\u6bd4\u4f60\u7528\u201dls -lR\u201d\u66f4\u53ef\u8bfb\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nfind . -type f -ls\r\n<\/pre>\n<p>\u4f7f\u7528xargs\u547d\u4ee4\u3002\u8fd9\u4e2a\u547d\u4ee4\u975e\u5e38\u7684\u5f3a\u5927\u3002\u6ce8\u610f\u6bcf\u884c\u4e0a\u4f60\u53ef\u4ee5\u63a7\u5236\u591a\u5c11\u4e2a\u4e1c\u897f\u7684\u6267\u884c\u3002\u5982\u679c\u4f60\u4e0d\u786e\u5b9a\u5b83\u662f\u6b63\u786e\u7684\u6267\u884c\uff0c\u5148\u4f7f\u7528xargs echo\u3002\u540c\u6837\uff0c-I{} \u4e5f\u975e\u5e38\u6709\u7528\u3002\u4f8b\u5b50\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nfind . -name \\*.py | xargs grep some_function\r\ncat hosts | xargs -I{} ssh root@{} hostname\r\n<\/pre>\n<p>\u5047\u8bbe\u4f60\u6709\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u6bd4\u5982\u4e00\u4e2aweb\u670d\u52a1\u5668\u65e5\u5fd7\uff0c\u5728\u67d0\u4e9b\u884c\u4e0a\u6709\u4e00\u4e9b\u503c\uff0c\u6bd4\u5982URL\u4e2d\u7684acct_id\u53c2\u6570\u3002\u5982\u679c\u4f60\u60f3\u7edf\u8ba1\u6bcf\u4e2aacct_id\u7684\u6240\u6709\u8bf7\u6c42\u8bb0\u5f55\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncat access.log | egrep -o \u2018acct_id=&#x5B;0-9]+\u2019 | cut -d= -f2 | sort | uniq -c | sort -rn\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u91cc\u8bf4\u7684\u201c\u745e\u58eb\u519b\u5200\u201d\u662f\u6307\u90a3\u4e9b\u7b80\u5355\u7684\u4e00\u53e5\u547d\u4ee4\u5c31\u80fd\u5b8c\u6210\u5176\u5b83\u9ad8\u7ea7\u8bed\u8a00\u4e00\u5927\u7247\u4ee3\u7801\u624d\u80fd\u5b8c\u6210\u7684\u5de5\u4f5c\u3002 \u4e0b\u9762\u7684\u8fd9\u4e9b\u5185\u5bb9\u662fQu [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2822","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/2822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=2822"}],"version-history":[{"count":3,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/2822\/revisions"}],"predecessor-version":[{"id":5005,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/2822\/revisions\/5005"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=2822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=2822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=2822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}