{"id":739,"date":"2019-12-24T09:54:25","date_gmt":"2019-12-24T01:54:25","guid":{"rendered":"http:\/\/prayerlaputa.com\/?p=739"},"modified":"2019-12-24T09:54:25","modified_gmt":"2019-12-24T01:54:25","slug":"shell%e8%84%9a%e6%9c%ac%e6%89%a7%e8%a1%8c%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"http:\/\/prayerlaputa.com\/?p=739","title":{"rendered":"shell\u811a\u672c\u6267\u884c\u65b9\u5f0f"},"content":{"rendered":"<p>\u4e00\u4e2a\u89c4\u8303\u7684Shell\u811a\u672c\u5728\u7b2c\u4e00\u884c\u4f1a\u6307\u51fa\u7531\u54ea\u4e2a\u7a0b\u5e8f\uff08\u89e3\u91ca\u5668\uff09\u6765\u6267\u884c\u811a\u672c\u4e2d\u7684\u5185\u5bb9\uff0c\u8fd9\u4e00\u884c\u5185\u5bb9\u5728Linux bash\u7684\u7f16\u7a0b\u4e00\u822c\u4e3a\uff1a<\/p>\n<pre class=\"language-\" data-role=\"codeBlock\" data-info=\"\"><code>#\uff01\/bin\/bash\r\n<\/code><\/pre>\n<p>\u6216<\/p>\n<pre class=\"language-\" data-role=\"codeBlock\" data-info=\"\"><code>#\uff01\/bin\/sh\r\n<\/code><\/pre>\n<p><strong>\u6ce8\u610f<\/strong><\/p>\n<ul>\n<li>\u5728Shell\u4e2d\u5982\u679c\u4e00\u884c\u7684\u7b2c\u4e00\u4e2a\u5b57\u6bcd\u662f#,\u5219\u662f\u6ce8\u91ca\uff0c\u4f46\u662f\u4e0a\u9762\u4e24\u4e2a\u662f\u5199\u5728\u7b2c\u4e00\u884c\uff0c\u6240\u4ee5\u4e0d\u662f\u811a\u672c\u6ce8\u91ca\u884c\uff0c\u5982\u679c\u5199\u5728\u67d0\u4e2a\u547d\u4ee4\u4e4b\u540e\uff0c\u5219\u53d8\u6210\u6ce8\u91ca\u884c\u3002<\/li>\n<li>sh\u4e3abash\u7684\u8f6f\u94fe\u63a5\uff0c\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u811a\u672c\u7684\u5f00\u5934\u4f7f\u7528\u201c#!\/bin\/bash\u201d\u548c\u201c#!\/bin\/sh\u201d\u662f\u6ca1\u6709\u533a\u522b\u7684\uff0c\u4f46\u66f4\u89c4\u8303\u7684\u5199\u6cd5\u662f\u5728\u811a\u672c\u7684\u5f00\u5934\u4f7f\u7528\u201c#!\/bin\/bash\u201d\u3002<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h1 id=\"shell%E8%84%9A%E6%9C%AC%E6%89%A7%E8%A1%8C%E6%96%B9%E5%BC%8F-1\" class=\"mume-header\">shell\u811a\u672c\u6267\u884c\u65b9\u5f0f<\/h1>\n<p>\u67093\u79cd\u65b9\u5f0f\uff1a<\/p>\n<h3 id=\"bash-script-name%E6%88%96%E6%98%AFsh-script-name\" class=\"mume-header\">bash script-name\u6216\u662fsh script-name<\/h3>\n<p>\u5f53\u811a\u672c\u6587\u4ef6\u672c\u8eab\u6ca1\u6709\u53ef\u6267\u884c\u6743\u9650\u65f6\u5e38\u4f7f\u7528\u7684\u65b9\u6cd5\uff0c\u6216\u8005\u811a\u672c\u6587\u4ef6\u5f00\u5934\u6ca1\u6709\u6307\u5b9a\u89e3\u91ca\u5668\u65f6\u9700\u8981\u4f7f\u7528\u7684\u65b9\u6cd5\u3002<br \/>\n<strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<blockquote><p>\u5c3d\u91cf\u4e0d\u8981\u7528<code>sh script-name<\/code>\u53bb\u6267\u884c\u811a\u672c\uff0c\u7406\u7531\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>\u811a\u672c\u5df2\u7ecf\u662f\u53ef\u6267\u884c\u6a21\u5f0f\u7684\uff0c\u5728\u91cc\u9762\u6307\u5b9a\u7684\u662fbash\uff0c\u64cd\u4f5c\u66f4\u7b80\u5355\u4e9b\u3002<br \/>\n\u811a\u672c\u4e2d\u603b\u662f\u58f0\u660e\u4e0a\u786e\u5b9a\u7684shell\uff08\u5982bash\uff09\u662f\u597d\u7684\u5b9e\u8df5\uff1a #!\/bin\/bash\u3002<\/li>\n<li>\u4e0d\u540c\u7684shell\uff08sh\u3001bash\u3001zsh\u3001fish\u3001csh\u3001tcsh\u3001ksh\u3001ash\u3001dash\u2026\u2026\uff09\u6709\u5404\u79cd\u5dee\u5f02\uff0c\u6df1\u5751\u52ff\u5165\u3002<br \/>\n\u76ee\u524d\u4e3b\u6d41\u7684\u662fbash\/zsh\u3002\u66f4\u591ashell\u7684\u4fe1\u606f \u53c2\u89c1\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Comparison_of_command_shells\">https:\/\/en.wikipedia.org\/wiki\/Comparison_of_command_shells<\/a><\/li>\n<li>sh\u53ef\u80fd\u662f\u4e2a\u7b26\u53f7\u94fe\u63a5\uff0c\u53ef\u80fd\u94fe\u63a5\u5230\u4e0d\u540c\u7684shell\uff0c\u5982\u6709\u7684Ubuntu\u7248\u672c\uff0csh\u662f\u94fe\u63a5\u5230dash\u7684\u3002<\/li>\n<\/ul>\n<\/blockquote>\n<p>\u53c2\u89c1\uff1a<a href=\"https:\/\/github.com\/oldratlee\/useful-scripts\/issues\/85\">DO NOT run script file by sh | \u4e0d\u8981\u4ee5<code>sh foo-script<\/code>\u7684\u65b9\u5f0f\u8fd0\u884c\u811a\u672c #85<\/a><\/p>\n<h3 id=\"pathscript-name%E6%88%96%E8%80%85script-name\" class=\"mume-header\">path\/script-name\u6216\u8005.\/script-name<\/h3>\n<p>\u5728\u5f53\u524d\u8def\u5f84\u4e0b\u6267\u884c\u811a\u672c\uff08\u811a\u672c\u9700\u8981\u6709\u6267\u884c\u6743\u9650\uff09.<br \/>\n\u4f53\u65b9\u6cd5\u4e3a:<code>chmod a+x script-name<\/code>\u3002\u7136\u540e\u901a\u8fc7\u6267\u884c\u811a\u672c\u7edd\u5bf9\u8def\u5f84\u6216\u8005\u76f8\u5bf9\u8def\u5f84\u5c31\u53ef\u4ee5\u6267\u884c\u811a\u672c\u4e86\u3002<\/p>\n<h3 id=\"source-script-name%E6%88%96%E8%80%85-script-name\" class=\"mume-header\">source script-name\u6216\u8005. script-name<\/h3>\n<p>\u8bfb\u5165\u811a\u672c\u5e76\u6267\u884c\u811a\u672c\uff0c\u5373\u5728\u5f53\u524dShell\u4e2d\u6267\u884csource\u6216\u201c.\u201d\u52a0\u8f7d\u5e76\u6267\u884c\u7684\u76f8\u5173\u811a\u672c\u6587\u4ef6\u7684\u547d\u4ee4\u53ca\u8bed\u53e5\uff0c<strong>\u800c\u4e0d\u662f\u4ea7\u751f\u4e00\u4e2a\u5b50Shell<\/strong>\u6765\u6267\u884c\u6587\u4ef6\u4e2d\u7684\u547d\u4ee4\u3002<\/p>\n<p>3\u79cdshell\u6267\u884c\u65b9\u5f0f\u5177\u4f53\u533a\u522b\u3001\u793a\u4f8b\u53c2\u89c1<a href=\"https:\/\/blog.csdn.net\/timchen525\/article\/details\/76407735\">Linux \u4e2d\u6267\u884cShell \u811a\u672c\u7684\u65b9\u5f0f\uff08\u4e09\u79cd\u65b9\u6cd5\uff09<\/a><\/p>\n<h1 id=\"%E5%8F%82%E8%80%83%E6%96%87%E6%A1%A3\" class=\"mume-header\">\u53c2\u8003\u6587\u6863<\/h1>\n<ul>\n<li><a href=\"https:\/\/github.com\/oldratlee\/useful-scripts\/issues\/85\">DO NOT run script file by sh | \u4e0d\u8981\u4ee5<code>sh foo-script<\/code>\u7684\u65b9\u5f0f\u8fd0\u884c\u811a\u672c #85<\/a><\/li>\n<li><a href=\"https:\/\/blog.csdn.net\/timchen525\/article\/details\/76407735\">Linux \u4e2d\u6267\u884cShell \u811a\u672c\u7684\u65b9\u5f0f\uff08\u4e09\u79cd\u65b9\u6cd5\uff09<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u4e2a\u89c4\u8303\u7684Shell\u811a\u672c\u5728\u7b2c\u4e00\u884c\u4f1a\u6307\u51fa\u7531\u54ea\u4e2a\u7a0b\u5e8f\uff08\u89e3\u91ca\u5668\uff09\u6765\u6267\u884c\u811a\u672c\u4e2d\u7684\u5185\u5bb9\uff0c\u8fd9\u4e00\u884c\u5185\u5bb9\u5728Linux bash <a href='http:\/\/prayerlaputa.com\/?p=739' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[7,68],"tags":[34,70],"_links":{"self":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/739"}],"collection":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=739"}],"version-history":[{"count":1,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/739\/revisions"}],"predecessor-version":[{"id":740,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=\/wp\/v2\/posts\/739\/revisions\/740"}],"wp:attachment":[{"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=739"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/prayerlaputa.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}