{"id":5340,"date":"2022-10-11T12:13:26","date_gmt":"2022-10-11T04:13:26","guid":{"rendered":"https:\/\/ixyzero.com\/blog\/?p=5340"},"modified":"2022-10-11T12:13:26","modified_gmt":"2022-10-11T04:13:26","slug":"%e9%87%8d%e6%8b%belinux%e6%96%87%e4%bb%b6%e9%87%8d%e5%ae%9a%e5%90%91","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/5340.html","title":{"rendered":"\u91cd\u62feLinux\u6587\u4ef6\u91cd\u5b9a\u5411"},"content":{"rendered":"\n<p>=Start=<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u7f18\u7531\uff1a<\/h4>\n\n\n\n<p>\u56e0\u4e3a\u5de5\u4f5c\u6027\u8d28\u7684\u53d8\u5316\uff0c\u6211\u5df2\u7ecf\u5f88\u4e45\u6ca1\u6709\u5173\u6ce8IDC\u5b89\u5168\u65b9\u9762\u7684\u5185\u5bb9\u4e86\uff08\u5f88\u4e45\u4e4b\u524d\u641e\u4e86\u4e00\u6bb5\u65f6\u95f4\u7684Bash\u6e90\u7801\u6539\u5199\u4ee5\u652f\u6301bash\u547d\u4ee4\u7684\u5b9e\u65f6\u8bb0\u5f55\u4ee5\u53ca\u57fa\u4e8e\u6b64\u7684\u6076\u610f\u547d\u4ee4\u5206\u6790\uff09\u3002\u524d\u6bb5\u65f6\u95f4\u5728\u7fa4\u91cc\u770b\u5230\u4e86\u4e00\u6761\u53cd\u5f39shell\u7684\u547d\u4ee4\uff0c\u548c\u4e4b\u524d\u6211\u6574\u7406\u65f6\u7565\u6709\u4e0d\u540c\u7684\u5730\u65b9\u5728\u4e8eopenssl\u547d\u4ee4\u7684\u5f15\u5165\uff0c\u5bf9\u8bf7\u6c42\u54cd\u5e94\u7684\u6d41\u91cf\u505a\u4e86\u52a0\u5bc6\uff0c\u4ee5\u89c4\u907f\u5728\u7f51\u7edc\u5c42\u9762\u7684\u5f02\u5e38\u68c0\u6d4b\u3002\u56e0\u4e3a\u4e4b\u524d\u53ea\u662f\u6536\u96c6\u548c\u8bb0\u5f55\u4e86\u5404\u7f16\u7a0b\u8bed\u8a00\u4e00\u53e5\u8bdd\u53cd\u5f39shell\u7684\u5185\u5bb9\uff0c\u4f46\u5e76\u6ca1\u6709\u5177\u4f53\u62c6\u89e3\u548c\u5b66\u4e60\u8fd9\u5176\u4e2d\u6d89\u53ca\u5230\u7684\u77e5\u8bc6\u70b9\u548c\u539f\u7406\uff0c\u6240\u4ee5\u8bb0\u5fc6\u5e76\u4e0d\u6df1\u523b\u3001\u547d\u4ee4\u6572\u8d77\u6765\u4e5f\u4e0d\u591f\u719f\u7ec3\uff08\u57fa\u672c\u5c31\u662f\u9760\u641c\u7d22\/\u590d\u5236\/\u7c98\u8d34\uff09\uff0c\u8d81\u7740\u6700\u8fd1\u6709\u70b9\u65f6\u95f4\uff0c\u518d\u6574\u7406\u548c\u5b66\u4e60\u4e00\u4e0b\uff0c\u52a0\u6df1\u8bb0\u5fc6\u65b9\u4fbf\u540e\u9762\u76f4\u63a5\u4f7f\u7528\u548c\u53c2\u8003\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u6b63\u6587\uff1a<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#fa0000\" class=\"has-inline-color\">Linux\u4e0b\u4e00\u5207\u7686\u6587\u4ef6\u3002<\/mark><\/strong><\/p>\n\n\n\n<p><strong>\u6587\u4ef6\u63cf\u8ff0\u7b26(fd,file descriptor)\u662f\u4e00\u4e2a\u975e\u8d1f\u6574\u6570\uff0c\u7528\u4ee5\u6807\u660e\u6bcf\u4e00\u4e2a\u88ab\u8fdb\u7a0b\u6240\u6253\u5f00\u7684\u6587\u4ef6\uff08\u5e38\u89c4\u6587\u4ef6\u3001\u76ee\u5f55\u3001\u5b57\u7b26\u8bbe\u5907\u3001\u5757\u8bbe\u5907\u3001\u5957\u63a5\u5b57\u3001\u6253\u5370\u673a\u3001\u8fdb\u7a0b\u3001\u7ebf\u7a0b\u3001\u7ba1\u9053\u7b49\uff09\u3002<\/strong><\/p>\n\n\n\n<p><strong>Linux\u4e0b\u6587\u4ef6\u6240\u6709\u8f93\u5165\u8f93\u51fa\u90fd\u662f\u7531\u8be5\u8fdb\u7a0b\u6240\u6709\u6253\u5f00\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u63a7\u5236\u7684\u3002<\/strong>Linux\u4e0b\u4e00\u4e2a\u7a0b\u5e8f\u542f\u52a8\u4e4b\u540e\u9ed8\u8ba4\u4f1a\u6709\u4e09\u4e2a\u6587\u4ef6\u63cf\u8ff0\u7b26\uff08\u6807\u51c6\u8f93\u5165-0\u3001\u6807\u51c6\u8f93\u51fa-1\u3001\u9519\u8bef\u8f93\u51fa-2\uff09\uff0c\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\u5982\u679c\u60f3\u8ba9\u5b83\u7684\u8f93\u51fa\u4e0d\u76f4\u63a5\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\uff0c\u800c\u662f\u8f93\u51fa\u5230\u6587\u4ef6\u6216\u8005\u5176\u4ed6\u8bbe\u5907\uff0c\u6b64\u65f6\u6211\u4eec\u5c31\u9700\u8981\u8fdb\u884c\u6587\u4ef6\u91cd\u5b9a\u5411\u3002<\/p>\n\n\n\n<p>The order of redirection is important, and they should be read left to right.<br>Redirections are processed in the order they appear, from left to right.<br><mark style=\"background-color:rgba(0, 0, 0, 0);color:#ff0000\" class=\"has-inline-color\"><strong>\u91cd\u5b9a\u5411\u7684\u987a\u5e8f\u662f\u975e\u5e38\u91cd\u8981\u7684<\/strong>\uff08\u56e0\u4e3a\u5b83\u4f1a\u5f71\u54cd\u6700\u7ec8\u7684\u7ed3\u679c\uff09\uff0c\u5b83\u4eec\u662f<strong>\u4ece\u5de6\u5230\u53f3<\/strong>\u4f9d\u6b21\u8fdb\u884c\u5904\u7406\u7684\u3002<\/mark><\/p>\n\n\n\n<p>\u4e0b\u9762\u7b80\u5355\u6574\u7406\u4e86 bash \u624b\u518c\u4e2d\u91cd\u5b9a\u5411\u4e00\u8282\u4e2d\u7684\u5185\u5bb9\uff08\u5185\u5bb9\u6839\u636e\u4e2a\u4eba\u7ecf\u9a8c\u505a\u4e86\u4e00\u4e9b\u7cbe\u7b80\uff09\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u91cd\u5b9a\u5411\u8f93\u5165<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5c06 word \u5c55\u5f00\u4e4b\u540e\u7684\u8f93\u51fa\u4f5c\u4e3a\u6587\u4ef6\u63cf\u8ff0\u7b26n\uff08\u5982\u679cn\u6ca1\u6709\u6307\u5b9a\uff0c\u5219\u9ed8\u8ba4\u4e3a0\uff0c\u8868\u793astdin\uff09\u7684\u8f93\u5165\n&#91;n]&lt;word\n\n# \u6837\u4f8b\uff1a\u5728\u7ec8\u7aef\u4e2d\u663e\u793a\u6587\u4ef6\u7684\u5185\u5bb9\uff08\u5c06\u6587\u4ef6\u7684\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\u6807\u51c6\u8f93\u51650\u4e0a\uff09\n$ &lt;file_name # \u7b49\u4ef7\u4e8e cat file_name \u547d\u4ee4\nnihao\ntest\nexit<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u91cd\u5b9a\u5411\u8f93\u51fa<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5c06\u6587\u4ef6\u63cf\u8ff0\u7b26n\uff08\u5982\u679cn\u6ca1\u6709\u6307\u5b9a\uff0c\u5219\u9ed8\u8ba4\u4e3a1\uff0c\u8868\u793astdout\uff09\u7684\u8f93\u51fa\u91cd\u5b9a\u5411\u5230 word \u5c55\u5f00\u4e4b\u540e\u7528\u4e8e\u8f93\u5165\u7684\u6587\u4ef6\u4e2d\uff0c\u9664\u4e86 &gt; \u64cd\u4f5c\u7b26\u4e4b\u5916\u8fd8\u53ef\u4ee5\u7528\u7ba1\u9053\u64cd\u4f5c\u7b26 |\n&#91;n]&gt;&#91;|]word<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#ff0000\" class=\"has-inline-color\">\u91cd\u5b9a\u5411\u6807\u51c6\u8f93\u51fa\u548c\u9519\u8bef\u8f93\u51fa<\/mark><\/strong>\uff08\u8fd9\u4e2a\u5f88\u6709\u7528\uff0c\u5efa\u8bae\u591a\u770b\u770b\uff09<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u67092\u79cd\u683c\u5f0f\u7684\u5199\u6cd5\n\n# \u5199\u6cd5\u4e00\uff0c\u63a8\u8350\u7684\u7b80\u5199\u7528\u6cd5\n&amp;&gt;word\n\n# \u5199\u6cd5\u4e8c\n&gt;&amp;word\n\n# \u4e0a\u9762\u4e24\u79cd\u5199\u6cd5\u3010\u5efa\u8bae\u4f7f\u7528\u7b2c\u4e00\u79cd\u3011\uff0c\u90fd\u7b49\u4ef7\u4e8e\u4e0b\u9762\u8fd9\u79cd\u66f4\u6613\u4e8e\u7406\u89e3\u7684\u5199\u6cd5\n&gt;word 2&gt;&amp;1<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5c06\u6807\u51c6\u8f93\u51fa\u548c\u9519\u8bef\u8f93\u51fa\u8fdb\u884c\u8ffd\u52a0\u5f0f\u91cd\u5b9a\u5411<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5199\u6cd5\u4e00\uff08\u548c\u4e0a\u9762\u7684\u76f8\u6bd4\u53ea\u662f\u5c06\u8986\u5199&gt;\u6539\u6210\u4e86\u8ffd\u52a0&gt;&gt;\uff09\n&amp;&gt;&gt;word\n\n# \u7b49\u4ef7\u5199\u6cd5\uff0c\u66f4\u5bb9\u6613\u7406\u89e3\uff0c\u66f4\u4e0d\u5bb9\u6613\u5199\u9519\n&gt;&gt;word 2&gt;&amp;1<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Here Documents<\/strong>\uff08\u90e8\u5206\u573a\u666f\u5f88\u6709\u7528\uff09<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9700\u8981\u989d\u5916\u8bf4\u660e\u7684\u662f\uff0c\u8fd9\u91cc\u8981\u7528 cat \u800c\u4e0d\u662f echo \u624d\u80fd\u628a\u5185\u5bb9\u6253\u5370\u51fa\u6765\uff0c\u56e0\u4e3a\u662f documents \u800c\u4e0d\u662f strings\n$ cat &lt;&lt;diffstring\nheredoc&gt; this is 1st line of here documents\nheredoc&gt; 2nd line\nheredoc&gt; 3rd line\nheredoc&gt; 4th line\nheredoc&gt;        5th line with '\\t' at begin of line\nheredoc&gt;  last line with ' ' at begin of line\nheredoc&gt; diffstring\n\nthis is 1st line of here documents\n2nd line\n3rd line\n4th line\n    5th line with '\\t' at begin of line\n last line with ' ' at begin of line\n$\n# \u76f8\u6bd4\u4e0a\u9762\u591a\u4e86\u4e00\u4e2a\u7834\u6298\u53f7\uff0c\u7528\u4e8e\u5220\u9664\u6bcf\u4e00\u884c\u5185\u5bb9\u4e2d\u884c\u9996\u7684\u5236\u8868\u7b26\n$ cat &lt;&lt;-diffstring\nheredocd&gt; this is 1st line\nheredocd&gt;       2nd line with '\\t' at begin of line\nheredocd&gt;  3rd line with ' ' at begin of line\nheredocd&gt;               4th line with 2*'\\t' at begin of line\nheredocd&gt; 5th line\nheredocd&gt; diffstring\n\nthis is 1st line\n2nd line with '\\t' at begin of line\n 3rd line with ' ' at begin of line\n4th line with 2*'\\t' at begin of line\n5th line\n\n# \u5229\u7528 here-documents \u7684\u7279\u6027\u5728shell\u811a\u672c\u4e2d\u5c06\u7279\u5b9a\u5185\u5bb9\u5199\u5165\u6587\u4ef6\uff08\u8d77\u5230\u7c7b\u4f3c\u5185\u5d4c\u6587\u4ef6\u7684\u529f\u80fd\uff09\n$ cat &lt;&lt; EOF &gt; \/tmp\/yourfilehere\nThese contents will be written to the file.\n        This line is indented.\nEOF<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>Here Strings<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u8bf4\u660e\uff0c\u5728 &lt;&lt;&lt; \u540e\u9762\u7684\u7b2c\u4e00\u4e2a\u5b57\u6bb5\u4e0d\u4f1a\u663e\u793a\n$ echo &lt;&lt;&lt;diffstring 1,2,3,4,5 line\n1,2,3,4,5 line\n$ echo &lt;&lt;&lt; content here\nhere\n$ echo &lt;&lt;&lt;no_display content here\ncontent here<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><strong><mark style=\"background-color:rgba(0, 0, 0, 0);color:#ff0000\" class=\"has-inline-color\">\u590d\u5236\u6587\u4ef6\u63cf\u8ff0\u7b26<\/mark><\/strong>\uff08\u4e2a\u4eba\u5efa\u8bae\u4e3a\u4e86\u53ef\u8bfb\u6027\uff0c\u6700\u597d\u4e0d\u8981\u7b80\u5199\uff09<\/li><\/ul>\n\n\n\n<p>\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u590d\u5236\u8fd9\u4e2a\u5730\u65b9\u628a\u6211\u7ed5\u4e86\u597d\u4e45\uff0c\u4e3b\u8981\u5728\u4e8egnu\u7684bash\u624b\u518c\u548cAdvanced Bash-Scripting Guide\u4e2d\u7684\u89e3\u91ca\u4e0d\u592a\u4e00\u6837\uff0c\u800c\u4e14\u5b9e\u9645\u6d4b\u8bd5\u53d1\u73b0\u4e0d\u540cshell\u4e2d\u7684\u652f\u6301\u60c5\u51b5\u548c\u8868\u73b0\u4e5f\u4e0d\u4e00\u81f4\uff0c\u6240\u4ee5\u6682\u65f6\u4e5f\u4e0d\u591a\u7ea0\u7ed3\u4e86\uff0c\u8d77\u7801\u80fd\u5c06\u6211\u4e2a\u4eba\u7684\u7ecf\u9a8c\u548c\u624b\u518c\u4e2d\u7684\u8bf4\u660e\u5bf9\u4e0a\uff0c\u540e\u9762\u5728\u78b0\u5230\u7279\u6b8a\u60c5\u51b5\u5c31\u53ef\u4ee5\u6309\u4e2a\u4eba\u7ecf\u9a8c\u8fdb\u884c\u5408\u7406\u7684\u89e3\u91ca\u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u7ecf\u8fc7\u5b9e\u9645\u6d4b\u8bd5\u53d1\u73b0\u5728\u4e0d\u540c\u79cd\u7c7b\u548c\u7248\u672c\u7684shell\u4e0a\u91cd\u5b9a\u5411\u4e2d\u7684\u590d\u5236\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u884c\u4e3a\u4e0d\u4e00\u81f4\uff08\u5f88\u53ef\u80fd\u8fd8\u4e0d\u751f\u6548\uff09\n# \u6240\u4ee5\u8fd9\u4e00\u5185\u5bb9\u5148\u6309\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u7406\u89e3\uff0c\u5230\u4e86\u5b9e\u9645\u9700\u8981\u7528\u7684\u65f6\u5019\uff0c\u9700\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u6d4b\u8bd5\u9a8c\u8bc1\u4ee5\u627e\u51fa\u5b9e\u9645\u53ef\u884c\u7684\u5177\u4f53\u65b9\u6cd5\/\u547d\u4ee4\n\n\n&#91;n]&lt;&amp;word #\u8868\u793a\u7528 word \u6269\u5c55\u51fa\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u503c\u8986\u76d6 n \uff0c**\u6700\u540eword\u548cn\u7684\u503c\u90fd\u76f8\u7b49\uff0c\u90fd\u662f\u539f\u5148word\u7684\u6307\u5411**\uff0c\u5373\u7528word\u505a\u4e3an\u7684\u8f93\u5165\uff0cn\u9ed8\u8ba4\u4e3a0\u5373\u6807\u51c6\u8f93\u5165\n\n&#91;n]&gt;&amp;word #\u5c06\u6587\u4ef6\u63cf\u8ff0\u7b26 n \u4ee3\u8868\u7684\u6587\u4ef6\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\u4e86 word \u4e0a\uff0c**\u6700\u540eword\u548cn\u7684\u503c\u90fd\u76f8\u7b49\uff0c\u90fd\u662f\u539f\u5148word\u7684\u6307\u5411**\uff0c\u8f93\u51fa\u5230n\u7684\u4e5f\u90fd\u540c\u6837\u8f93\u51fa\u5230\u4e86word\uff0c\u7279\u6b8a\u60c5\u51b5\u82e5n\u7701\u7565\uff0c\u5c31\u662f\u5c06\u6807\u51c6\u8f93\u51fa\u548c\u9519\u8bef\u8f93\u51fa\u90fd\u8f93\u51fa\u5230\u4e86word\u4e2d\n\n# \u5373\uff0c\u4e0d\u7ba1\u662f\u590d\u5236\u8f93\u5165\u8fd8\u662f\u590d\u5236\u8f93\u51fa\uff0c\u6709\u4e00\u4e2a\u70b9\u662f\u76f8\u540c\u7684\uff0c\u6700\u540e\u4e24\u8005\u7684\u503c\u76f8\u540c\uff0c\u90fd\u662f\u539f\u5148\u7684word\uff0c\u533a\u522b\u5728\u4e8e\u4e00\u4e2a\u7528word\u4f5c\u4e3a\u8f93\u5165\uff0c\u4e00\u4e2a\u7528word\u4f5c\u4e3a\u8f93\u51fa\n\n# \u4e0d\u7ba1\u662f\u54ea\u4e2a\uff0c\u6700\u540e word \u548c n \u7684\u503c\u90fd\u662f\u76f8\u7b49\u7684\uff0c\u4e14\u90fd\u662fword\u7684\u503c\uff0c\u6240\u4ee5 0&gt;&amp;1 == 0&lt;&amp;1 == &lt;&amp;1 \u8fd93\u8005\u7b49\u4ef7\uff08\u8f93\u5165\u8f93\u51fa\u8fde\u63a5\u6210\u4e86\u73af\u72b6\uff0c\u5728\u7ec8\u7aef\u4ea4\u4e92\u7684\u8868\u73b0\u5c31\u662f\u8f93\u5165\u4ec0\u4e48\u5c31\u8f93\u51fa\u4ec0\u4e48\uff09\n\n\n# \u7528\u4e8e\u590d\u5236\u3010\u8f93\u5165\u3011\u6587\u4ef6\u63cf\u8ff0\u7b26\uff0c\u5c06 word \u5c55\u5f00\u4e4b\u540e\u7684\u6587\u4ef6\u7684\u8f93\u5165\u590d\u5236\u5230\u6587\u4ef6\u63cf\u8ff0\u7b26n\u4e0a\uff0c\u82e5n\u6ca1\u6709\u6307\u5b9a\u5219\u9ed8\u8ba4\u4e3a0\n&#91;n]&lt;&amp;word\n\n# \u7528\u4e8e\u590d\u5236\u3010\u8f93\u51fa\u3011\u6587\u4ef6\u63cf\u8ff0\u7b26\uff08\u6bd4\u8f83\u597d\u7406\u89e3\uff09\uff0cn\u9ed8\u8ba4\u4e3a1\uff0c\u7279\u522b\u7684\u5f53n\u7701\u7565\u65f6\u5c31\u662f\u4e4b\u524d\u4ecb\u7ecd\u8fc7\u7684\u2014\u2014\u91cd\u5b9a\u5411\u6807\u51c6\u8f93\u51fa\u548c\u9519\u8bef\u8f93\u51fa\n&#91;n]&gt;&amp;word\n\ni&gt;&amp;j\n  # Redirects file descriptor i to j. \"i\" defaults to 1, if not set.\n  # All output of file pointed to by i gets sent to file pointed to by j.\n\n0&gt;&amp;1 (same as 0&lt;&amp;1 or &lt;&amp;1) duplicates fd 1 to 0 as well (fd 0 is made to point to the same resource as pointed to by fd 1).<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u66f4\u65b0\u6587\u4ef6\u63cf\u8ff0\u7b26\uff08\u76f8\u6bd4\u4e8e\u4e0a\u9762\u7684\u590d\u5236\uff0c\u53ea\u662f\u589e\u52a0\u4e86\u590d\u5236\u540e\u5173\u95ed\u539f\u6587\u4ef6\u63cf\u8ff0\u7b26\u7684\u52a8\u4f5c\uff09<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5c06 digit \u8fd9\u4e2a\u6570\u5b57\u6307\u5b9a\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u66f4\u65b0\u5230\u6587\u4ef6\u63cf\u8ff0\u7b26n\u4e0a\uff0c\u5728\u6b64\u4e4b\u540e\u539f digit \u6587\u4ef6\u63cf\u8ff0\u7b26\u5c31\u4f1a\u5173\u95ed\uff0c\u82e5n\u6ca1\u6709\u6307\u5b9a\u5219\u8868\u793a\u4e3a\u6807\u51c6\u8f93\u51650\n&#91;n]&lt;&amp;digit-\n\n# \u5c06 digit \u8fd9\u4e2a\u6570\u5b57\u6307\u5b9a\u7684\u6587\u4ef6\u63cf\u8ff0\u7b26\u66f4\u65b0\u5230\u6587\u4ef6\u63cf\u8ff0\u7b26n\u4e0a\uff0c\u5728\u6b64\u4e4b\u540e\u539f digit \u6587\u4ef6\u63cf\u8ff0\u7b26\u5c31\u4f1a\u5173\u95ed\uff0c\u82e5n\u6ca1\u6709\u6307\u5b9a\u5219\u8868\u793a\u4e3a\u6807\u51c6\u8f93\u51fa1\n&#91;n]&gt;&amp;digit-<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u6253\u5f00\u6587\u4ef6\u63cf\u8ff0\u7b26\u7528\u4e8e\u6587\u4ef6\u8bfb\u5199<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5c06 word \u5c55\u5f00\u4e4b\u540e\u7684\u6587\u4ef6\u7684\u8f93\u5165\u548c\u8f93\u51fa\u7ed1\u5b9a\u5230\u6587\u4ef6\u63cf\u8ff0\u7b26n\uff08\u5982\u679cn\u6ca1\u6709\u6307\u5b9a\uff0c\u5219\u9ed8\u8ba4\u4e3a0\uff0c\u8868\u793astdin\uff09\u4e0a\n&#91;n]&lt;&gt;word\n\n# \u4e3e\u4f8b\n# \u5c06n\u7701\u7565\uff0c\u5219\u8868\u793a\u65b0\u5efa\u4e00\u4e2a\u540d\u53eb word \u7684\u7a7a\u6587\u4ef6\n$ &lt;&gt; word\n\n# \u5c06n\u8bbe\u7f6e\u4e3a1\uff0c\u5219\u8868\u793a\u5c06\u5f53\u524d\u4ece\u7ec8\u7aef\u8f93\u5165\u7684\u4efb\u4f55\u5185\u5bb9\uff08\u5728\u4f60\u6309\u4f4f Ctrl-d \u8868\u793a\u8f93\u5165\u7ed3\u675f\u4e4b\u524d\uff09\u5199\u5165\u540d\u53eb word \u7684\u6587\u4ef6\u4e2d\n$ 1&lt;&gt;word<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n\n\n\n<p>3.6.8 Duplicating File Descriptors<br><a href=\"https:\/\/www.gnu.org\/software\/bash\/manual\/html_node\/Redirections.html#Duplicating-File-Descriptors\">https:\/\/www.gnu.org\/software\/bash\/manual\/html_node\/Redirections.html#Duplicating-File-Descriptors<\/a><\/p>\n\n\n\n<p>Chapter 20. I\/O Redirection<br><a href=\"https:\/\/tldp.org\/LDP\/abs\/html\/io-redirection.html#IOREDIRREF\">https:\/\/tldp.org\/LDP\/abs\/html\/io-redirection.html#IOREDIRREF<\/a><\/p>\n\n\n\n<p>Order of redirections<br><a href=\"https:\/\/unix.stackexchange.com\/questions\/37660\/order-of-redirections\/176214#176214\">https:\/\/unix.stackexchange.com\/questions\/37660\/order-of-redirections\/176214#176214<\/a><\/p>\n\n\n\n<p>Shell redirection i\/o order<br><a href=\"https:\/\/stackoverflow.com\/questions\/17975232\/shell-redirection-i-o-order\">https:\/\/stackoverflow.com\/questions\/17975232\/shell-redirection-i-o-order<\/a><\/p>\n\n\n\n<p>exec redirects in bash<br><a href=\"https:\/\/unix.stackexchange.com\/questions\/184125\/exec-redirects-in-bash\">https:\/\/unix.stackexchange.com\/questions\/184125\/exec-redirects-in-bash<\/a><\/p>\n\n\n\n<p>20.1. Using exec<br><a href=\"https:\/\/tldp.org\/LDP\/abs\/html\/x17974.html\">https:\/\/tldp.org\/LDP\/abs\/html\/x17974.html<\/a><\/p>\n\n\n\n<p>Chapter 19. Here Documents<br><a href=\"https:\/\/tldp.org\/LDP\/abs\/html\/here-docs.html\">https:\/\/tldp.org\/LDP\/abs\/html\/here-docs.html<\/a><\/p>\n\n\n\n<p>Here Document And Here String<br><a href=\"https:\/\/www.baeldung.com\/linux\/heredoc-herestring\">https:\/\/www.baeldung.com\/linux\/heredoc-herestring<\/a><\/p>\n\n\n\n<p>Here document\u4f7f\u7528\u65b9\u6cd5\u603b\u7ed3<br><a href=\"https:\/\/blog.csdn.net\/liumiaocn\/article\/details\/86715953\">https:\/\/blog.csdn.net\/liumiaocn\/article\/details\/86715953<\/a><\/p>\n\n\n\n<p>How can I write a heredoc to a file in Bash script?<br><a href=\"https:\/\/stackoverflow.com\/questions\/2953081\/how-can-i-write-a-heredoc-to-a-file-in-bash-script\">https:\/\/stackoverflow.com\/questions\/2953081\/how-can-i-write-a-heredoc-to-a-file-in-bash-script<\/a><\/p>\n\n\n\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u56e0\u4e3a\u5de5\u4f5c\u6027\u8d28\u7684\u53d8\u5316\uff0c\u6211\u5df2\u7ecf\u5f88\u4e45\u6ca1\u6709\u5173\u6ce8IDC\u5b89\u5168\u65b9\u9762\u7684\u5185\u5bb9\u4e86\uff08\u5f88\u4e45\u4e4b\u524d\u641e\u4e86\u4e00\u6bb5\u65f6\u95f4\u7684B [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,12],"tags":[83,30,1863,1864,253],"class_list":["post-5340","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-tools","tag-bash","tag-linux","tag-redirections","tag-1864","tag-253"],"views":1778,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5340","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=5340"}],"version-history":[{"count":1,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5340\/revisions"}],"predecessor-version":[{"id":5341,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5340\/revisions\/5341"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=5340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=5340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=5340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}