{"id":586,"date":"2016-09-11T14:39:20","date_gmt":"2016-09-11T14:39:20","guid":{"rendered":"https:\/\/peloo.net\/?p=586"},"modified":"2016-09-29T15:09:38","modified_gmt":"2016-09-29T15:09:38","slug":"shell%e9%87%8d%e5%ae%9a%e5%90%91%ef%bc%86file%e3%80%8121%e3%80%8112%e7%9a%84%e5%8c%ba%e5%88%ab","status":"publish","type":"post","link":"https:\/\/peloo.net\/?p=586","title":{"rendered":"Shell\u91cd\u5b9a\u5411&amp;&gt;file\u30012&gt;&amp;1\u30011&gt;&amp;2\u7684\u533a\u522b"},"content":{"rendered":"<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5728UNIX\/Linux\u7cfb\u7edf\u4e2d\uff0c\u6bcf\u4e2a\u6253\u5f00\u7684\u6587\u4ef6\u90fd\u6709\u7cfb\u7edf\u8d4b\u4e88\u7684\u4e00\u4e2a\u6587\u4ef6\u63cf\u8ff0\u5b57\uff0c\u8fd9\u662f\u4e2a\u5c0f\u6574\u6570\u3002\u4e00\u4e2a\u6587\u4ef6\u88ab\u6253\u5f00\u540e\uff0c\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u7528\u8fd9\u4e2a\u63cf\u8ff0\u5b57\u6765\u5f15\u7528\u5bf9\u5e94\u7684\u6587\u4ef6\u3002\u7cfb\u7edf\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u81ea\u52a8\u6253\u5f00\u4e09\u4e2a\u6807\u51c6\u6587\u4ef6\uff08\u5373\u6807\u51c6\u8f93\u5165\u3001\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\u8f93\u51fa\uff09\uff0c\u5176\u6587\u4ef6\u63cf\u8ff0\u5b57\u5206\u522b\u4e3a0,1\u548c2\u3002<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:14px\"><span>shell\u4e0a:<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\"><strong><span>0\u8868\u793a\u6807\u51c6\u8f93\u5165<\/span><\/strong><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\"><strong><span>1\u8868\u793a\u6807\u51c6\u8f93\u51fa<\/span><\/strong><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\"><strong><span>2\u8868\u793a\u6807\u51c6\u9519\u8bef\u8f93\u51fa<\/span><\/strong><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\"><strong><span>&gt; \u9ed8\u8ba4\u4e3a\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\uff0c\u4e0e 1&gt; \u76f8\u540c<\/span><\/strong><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\"><strong><span>2&gt;&amp;1 \u610f\u601d\u662f\u628a \u6807\u51c6\u9519\u8bef\u8f93\u51fa \u91cd\u5b9a\u5411\u5230 \u6807\u51c6\u8f93\u51fa.<\/span><\/strong><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\"><strong><span>&amp;&gt;file \u610f\u601d\u662f\u628a \u6807\u51c6\u8f93\u51fa \u548c \u6807\u51c6\u9519\u8bef\u8f93\u51fa \u90fd\u91cd\u5b9a\u5411\u5230\u6587\u4ef6file\u4e2d<\/span><\/strong><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\"><strong><span>&nbsp;<\/span><\/strong><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">\u7528\u4f8b\u5b50\u8bf4\u8bdd\uff1a<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">1. grep da * 1&gt;&amp;2<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">2. rm -f $(find \/ -name core) &amp;&gt; \/dev\/null<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">\u4e0a\u9762\u4e24\u4f8b\u4e2d\u7684 &amp; \u5982\u4f55\u7406\u89e3\uff0c&amp;\u4e0d\u662f\u653e\u5230\u540e\u53f0\u6267\u884c\u5417?<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">\u725b\u89e3\uff1a<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">1.&amp;&gt;file\u6216n&gt;&amp;m\u5747\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u91cd\u5b9a\u5411\u7b26\u53f7\uff0c\u4e0d\u8981\u5206\u5f00\u6765\u7406\u89e3\u3002<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">2.\u660e\u786e\u6587\u4ef6\u548c\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u533a\u522b\u3002<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">3.&amp;&gt;file\u8868\u793a\u91cd\u5b9a\u5411\u6807\u51c6\u8f93\u51fa\u548c\u9519\u8bef\u5230\u6587\u4ef6<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">\u4f8b\u5982\uff1a<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">rm -f $(find \/ -name core) &amp;&gt; \/dev\/null\uff0c\/dev\/null\u662f\u4e00\u4e2a\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u6bd4\u8f83\u7279\u6b8a\uff0c\u6240\u6709\u4f20\u7ed9\u5b83\u7684\u4e1c\u897f\u5b83\u90fd\u4e22\u5f03\u6389\u3002<\/span>\n<\/p>\n<p>\n\t&nbsp;\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">4.n&gt;&amp;m\u8868\u793a\u4f7f\u6587\u4ef6\u63cf\u8ff0\u7b26n\u6210\u4e3a\u8f93\u51fa\u6587\u4ef6\u63cf\u8ff0\u7b26m\u7684\u526f\u672c\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\uff0c\u6709\u7684\u65f6\u5019\u4f60\u67e5\u627e\u6587\u4ef6\u7684\u65f6\u5019\u5f88\u5bb9\u6613\u4ea7\u751f\u65e0\u7528\u7684\u4fe1\u606f,<br \/>\n\t\u5982:2&gt;<br \/>\n\t\/dev\/null\u7684\u4f5c\u7528\u5c31\u662f\u4e0d\u663e\u793a\u6807\u51c6\u9519\u8bef\u8f93\u51fa\uff1b\u53e6\u5916\u5f53\u4f60\u8fd0\u884c\u67d0\u4e9b\u547d\u4ee4\u7684\u65f6\u5019,\u51fa\u9519\u4fe1\u606f\u4e5f\u8bb8\u5f88\u91cd\u8981,\u4fbf\u4e8e\u4f60\u68c0\u67e5\u662f\u54ea\u51fa\u4e86\u6bdb\u75c5,<br \/>\n\t\u5982:2&gt;&amp;1<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">\u4f8b\u5982\uff1a<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">\u6ce8\u610f\uff0c\u4e3a\u4e86\u65b9\u4fbf\u7406\u89e3\uff0c\u5fc5\u987b\u8bbe\u7f6e\u4e00\u4e2a\u73af\u5883\u4f7f\u5f97\u6267\u884cgrep da *\u547d\u4ee4\u4f1a\u6709\u6b63\u5e38\u8f93\u51fa\u548c\u9519\u8bef\u8f93\u51fa\uff0c\u7136\u540e\u5206\u522b\u4f7f\u7528\u4e0b\u9762\u7684\u547d\u4ee4\u751f\u6210\u4e09\u4e2a\u6587\u4ef6\uff1a<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">grep da * &gt; greplog1<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">grep da * &gt; greplog2 1&gt;&amp;2<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">grep da * &gt; greplog3 2&gt;&amp;1&nbsp; \/\/grep da * 2&gt; greplog4 1&gt;&amp;2 \u7ed3\u679c\u4e00\u6837<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">#\u67e5\u770bgreplog1\u4f1a\u53d1\u73b0\u91cc\u9762\u53ea\u6709\u6b63\u5e38\u8f93\u51fa\u5185\u5bb9<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">#\u67e5\u770bgreplog2\u4f1a\u53d1\u73b0\u91cc\u9762\u4ec0\u4e48\u90fd\u6ca1\u6709<\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px\">#\u67e5\u770bgreplog3\u4f1a\u53d1\u73b0\u91cc\u9762\u65e2\u6709\u6b63\u5e38\u8f93\u51fa\u5185\u5bb9\u53c8\u6709\u9519\u8bef\u8f93\u51fa\u5185\u5bb9<\/span>\n<\/p>\n<p>\n\t&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \u5728UNIX\/Linux\u7cfb\u7edf\u4e2d\uff0c\u6bcf\u4e2a\u6253\u5f00\u7684\u6587\u4ef6\u90fd\u6709\u7cfb\u7edf\u8d4b\u4e88\u7684\u4e00\u4e2a\u6587\u4ef6\u63cf\u8ff0\u5b57\uff0c\u8fd9\u662f\u4e2a\u5c0f\u6574\u6570\u3002\u4e00\u4e2a\u6587\u4ef6\u88ab\u6253\u5f00\u540e\uff0c\u7528\u6237\u53ef\u4ee5\u76f4\u63a5\u7528\u8fd9\u4e2a\u63cf\u8ff0\u5b57\u6765\u5f15\u7528\u5bf9\u5e94\u7684\u6587\u4ef6\u3002\u7cfb\u7edf\u4e3a\u6bcf\u4e2a\u8fdb\u7a0b\u81ea\u52a8\u6253\u5f00\u4e09\u4e2a\u6807\u51c6\u6587\u4ef6\uff08\u5373\u6807\u51c6\u8f93\u5165\u3001\u6807\u51c6\u8f93\u51fa\u548c\u6807\u51c6\u9519\u8bef\u8f93\u51fa\uff09\uff0c\u5176\u6587\u4ef6\u63cf\u8ff0\u5b57\u5206\u522b\u4e3a0,1\u548c2\u3002 &nbsp; shell\u4e0a: 0\u8868\u793a\u6807\u51c6\u8f93\u5165 1\u8868\u793a\u6807\u51c6\u8f93\u51fa 2\u8868\u793a\u6807\u51c6\u9519\u8bef\u8f93\u51fa &gt; \u9ed8\u8ba4\u4e3a\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\uff0c\u4e0e 1&gt; \u76f8\u540c 2&gt;&amp;1 \u610f\u601d\u662f\u628a \u6807\u51c6\u9519\u8bef\u8f93\u51fa \u91cd\u5b9a\u5411\u5230 \u6807\u51c6\u8f93\u51fa. &amp;&gt;file \u610f\u601d\u662f\u628a \u6807\u51c6\u8f93\u51fa \u548c \u6807\u51c6\u9519\u8bef\u8f93\u51fa \u90fd\u91cd\u5b9a\u5411\u5230\u6587\u4ef6file\u4e2d &nbsp; \u7528\u4f8b\u5b50\u8bf4\u8bdd\uff1a 1. grep da * 1&gt;&amp;2 2. rm -f $(find \/ -name core) &amp;&gt; \/dev\/null \u4e0a\u9762\u4e24\u4f8b\u4e2d\u7684 &amp; \u5982\u4f55\u7406\u89e3\uff0c&amp;\u4e0d\u662f\u653e\u5230\u540e\u53f0\u6267\u884c\u5417? &nbsp; \u725b\u89e3\uff1a &nbsp; 1.&amp;&gt;file\u6216n&gt;&amp;m\u5747\u662f\u4e00\u4e2a\u72ec\u7acb\u7684\u91cd\u5b9a\u5411\u7b26\u53f7\uff0c\u4e0d\u8981\u5206\u5f00\u6765\u7406\u89e3\u3002 &nbsp; 2.\u660e\u786e\u6587\u4ef6\u548c\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u533a\u522b\u3002 &nbsp; 3.&amp;&gt;file\u8868\u793a\u91cd\u5b9a\u5411\u6807\u51c6\u8f93\u51fa\u548c\u9519\u8bef\u5230\u6587\u4ef6 \u4f8b\u5982\uff1a rm -f $(find \/&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-586","post","type-post","status-publish","format-standard","hentry","category-linux-shell"],"aioseo_notices":[],"brizy_media":[],"_links":{"self":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=586"}],"version-history":[{"count":15,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/586\/revisions"}],"predecessor-version":[{"id":679,"href":"https:\/\/peloo.net\/index.php?rest_route=\/wp\/v2\/posts\/586\/revisions\/679"}],"wp:attachment":[{"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peloo.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}