{"id":233096,"date":"2022-01-04T09:26:46","date_gmt":"2022-01-04T01:26:46","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=233096"},"modified":"2021-12-27T19:27:33","modified_gmt":"2021-12-27T11:27:33","slug":"shell-function-classification","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/shell-function-classification.html","title":{"rendered":"Shell\u7684\u4f5c\u7528\u4e0e\u5206\u7c7b"},"content":{"rendered":"
1\u3001Shell\u7684\u4f5c\u7528<\/strong><\/div>\n

Shell\u9664\u4e86\u80fd\u89e3\u91ca\u7528\u6237\u8f93\u5165\u7684\u547d\u4ee4\uff0c\u5c06\u5b83\u4f20\u9012\u7ed9\u5185\u6838\uff0c\u8fd8\u53ef\u4ee5\uff1a<\/p>\n

\u8c03\u7528\u5176\u4ed6\u7a0b\u5e8f\uff0c\u7ed9\u5176\u4ed6\u7a0b\u5e8f\u4f20\u9012\u6570\u636e\u6216\u53c2\u6570\uff0c\u5e76\u83b7\u53d6\u7a0b\u5e8f\u7684\u5904\u7406\u7ed3\u679c\u3002
\n\u5728\u591a\u4e2a\u7a0b\u5e8f\u4e4b\u95f4\u4f20\u9012\u6570\u636e\uff0c\u628a\u4e00\u4e2a\u7a0b\u5e8f\u7684\u8f93\u51fa\u4f5c\u4e3a\u53e6\u4e00\u4e2a\u7a0b\u5e8f\u7684\u8f93\u5165\u3002
\nShell\u672c\u8eab\u4e5f\u53ef\u4ee5\u88ab\u5176\u4ed6\u7a0b\u5e8f\u8c03\u7528\u3002
\n\u7531\u6b64\u53ef\u89c1\uff0cShell\u662f\u5c06\u5185\u6838\u3001\u7a0b\u5e8f\u548c\u7528\u6237\u8fde\u63a5\u4e86\u8d77\u6765\u3002<\/p>\n

Shell\u672c\u8eab\u652f\u6301\u7684\u547d\u4ee4\u5e76\u4e0d\u591a\uff0c\u4f46\u662f\u5b83\u53ef\u4ee5\u8c03\u7528\u5176\u4ed6\u7684\u7a0b\u5e8f\uff0c\u6bcf\u4e2a\u7a0b\u5e8f\u5c31\u662f\u4e00\u4e2a\u547d\u4ee4\uff0c\u8fd9\u4f7f\u5f97Shell\u547d\u4ee4\u7684\u6570\u91cf\u53ef\u4ee5\u65e0\u9650\u6269\u5c55\uff0c\u5176\u7ed3\u679c\u5c31\u662fShell\u7684\u529f\u80fd\u975e\u5e38\u5f3a\u5927\uff0c\u5b8c\u5168\u80fd\u591f\u80dc\u4efb Linux \u7684\u65e5\u5e38\u7ba1\u7406\u5de5\u4f5c\uff0c\u5982\u6587\u672c\u6216\u5b57\u7b26\u4e32\u68c0\u7d22\u3001\u6587\u4ef6\u7684\u67e5\u627e\u6216\u521b\u5efa\u3001\u5927\u89c4\u6a21\u8f6f\u4ef6\u7684\u81ea\u52a8\u90e8\u7f72\u3001\u66f4\u6539\u7cfb\u7edf\u8bbe\u7f6e\u3001\u76d1\u63a7\u670d\u52a1\u5668\u6027\u80fd\u3001\u53d1\u9001\u62a5\u8b66\u90ae\u4ef6\u3001\u6293\u53d6\u7f51\u9875\u5185\u5bb9\u3001\u538b\u7f29\u6587\u4ef6\u7b49\u3002<\/p>\n

Shell\u5e76\u4e0d\u662f\u7b80\u5355\u7684\u5806\u780c\u547d\u4ee4\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u5728Shell\u4e2d\u7f16\u7a0b\uff0c\u8fd9\u548c\u4f7f\u7528 C\/C++\u3001Java\u3001Python \u7b49\u5e38\u89c1\u7684\u7f16\u7a0b\u8bed\u8a00\u5e76\u6ca1\u6709\u4ec0\u4e48\u4e24\u6837\u3002<\/p>\n

Shell\u867d\u7136\u6ca1\u6709 C\/C++\u3001Java\u3001Python \u7b49\u5f3a\u5927\uff0c\u4f46\u4e5f\u652f\u6301\u4e86\u57fa\u672c\u7684\u7f16\u7a0b\u5143\u7d20\uff0c\u4f8b\u5982\uff1a<\/p>\n

if...else \u9009\u62e9\u7ed3\u6784\uff0cswitch...case \u5f00\u5173\u8bed\u53e5\uff0cfor\u3001while\u3001until\u5faa\u73af\u3002
\n\u53d8\u91cf\u3001\u6570\u7ec4\u3001\u5b57\u7b26\u4e32\u3001\u6ce8\u91ca\u3001\u52a0\u51cf\u4e58\u9664\u3001\u903b\u8f91\u8fd0\u7b97\u7b49\u6982\u5ff5\u3002
\n\u51fd\u6570\uff0c\u5305\u62ec\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u51fd\u6570\u548c\u5185\u7f6e\u51fd\u6570\uff08\u4f8b\u5982 printf\u3001export\u3001eval \u7b49\uff09\u3002
\nShell\u4e5f\u662f\u4e00\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5b83\u7684\u7f16\u8bd1\u5668\uff08\u89e3\u91ca\u5668\uff09\u662fShell\u8fd9\u4e2a\u7a0b\u5e8f\u3002\u6211\u4eec\u5e73\u65f6\u6240\u8bf4\u7684Shell\uff0c\u6709\u65f6\u5019\u662f\u6307\u8fde\u63a5\u7528\u6237\u548c\u5185\u6838\u7684\u8fd9\u4e2a\u7a0b\u5e8f\uff0c\u6709\u65f6\u5019\u53c8\u662f\u6307Shell\u7f16\u7a0b\u3002<\/p>\n

Shell\u4e3b\u8981\u7528\u6765\u5f00\u53d1\u4e00\u4e9b\u5b9e\u7528\u7684\u3001\u81ea\u52a8\u5316\u7684\u5c0f\u5de5\u5177\uff0c\u800c\u4e0d\u662f\u7528\u6765\u5f00\u53d1\u5177\u6709\u590d\u6742\u4e1a\u52a1\u903b\u8f91\u7684\u4e2d\u5927\u578b\u8f6f\u4ef6\uff0c\u4f8b\u5982\u68c0\u6d4b\u8ba1\u7b97\u673a\u7684\u786c\u4ef6\u53c2\u6570\u3001\u4e00\u952e\u642d\u5efaWeb\u5f00\u53d1\u73af\u5883\u3001\u65e5\u5fd7\u5206\u6790\u7b49\uff0cShell\u90fd\u975e\u5e38\u5408\u9002\u3002<\/p>\n

\u4f7f\u7528Shell\u7684\u719f\u7ec3\u7a0b\u5ea6\u53cd\u6620\u4e86\u7528\u6237\u5bf9 Linux \u7684\u638c\u63e1\u7a0b\u5ea6\uff0c\u8fd0\u7ef4\u5de5\u7a0b\u5e08\u3001\u7f51\u7edc\u7ba1\u7406\u5458\u3001\u7a0b\u5e8f\u5458\u90fd\u5e94\u8be5\u5b66\u4e60Shell\u3002<\/p>\n

\u5c24\u5176\u662f Linux \u8fd0\u7ef4\u5de5\u7a0b\u5e08\uff0cShell\u66f4\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\uff0c\u662f\u5fc5\u987b\u638c\u63e1\u7684\u6280\u80fd\uff0c\u5b83\u4f7f\u5f97\u6211\u4eec\u80fd\u591f\u81ea\u52a8\u5316\u5730\u7ba1\u7406\u670d\u52a1\u5668\u96c6\u7fa4\uff0c\u5426\u5219\u4f60\u5c31\u5f97\u4e00\u4e2a\u4e00\u4e2a\u5730\u767b\u5f55\u6240\u6709\u7684\u670d\u52a1\u5668\uff0c\u5bf9\u6bcf\u4e00\u53f0\u670d\u52a1\u5668\u90fd\u8fdb\u884c\u76f8\u540c\u7684\u8bbe\u7f6e\uff0c\u800c\u8fd9\u4e9b\u670d\u52a1\u5668\u53ef\u80fd\u6709\u6210\u767e\u4e0a\u5343\u4e4b\u591a\uff0c\u4f1a\u6d6a\u8d39\u5927\u91cf\u7684\u65f6\u95f4\u5728\u91cd\u590d\u6027\u7684\u5de5\u4f5c\u4e0a\u3002<\/p>\n

2\u3001Shell\u7684\u5206\u7c7b<\/strong><\/div>\n

\u76ee\u524dShell\u7684\u7248\u672c\u6709\u5f88\u591a\u79cd\uff0c\u5982BourneShell\u3001CShell\u3001Bash\u3001ksh\u3001tcsh\u7b49\uff0c\u5b83\u4eec\u5404\u6709\u7279\u70b9\u3002<\/p>\n

\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n

\"\"<\/p>\n

\u4e0b\u9762\u7b80\u8981\u4ecb\u7ecd\u51e0\u4e2a\u91cd\u70b9\u7684Shell\u7248\u672c\u3002<\/p>\n

\u6700\u91cd\u8981\u7684Shell\u662fBourneShell\uff0c\u8fd9\u4e2a\u547d\u540d\u662f\u4e3a\u4e86\u7eaa\u5ff5\u6b64Shell\u7684\u53d1\u660e\u8005Steven Bourne\u3002\u4ece 1979 \u5e74\u8d77\uff0cUNIX \u5c31\u5f00\u59cb\u4f7f\u7528BourneShell\u3002BourneShell\u7684\u4e3b\u6587\u4ef6\u540d\u4e3ash\uff0c\u5f00\u53d1\u4eba\u5458\u4fbf\u4ee5sh\u4f5c\u4e3aBourneShell\u7684\u4e3b\u8981\u8bc6\u522b\u540d\u79f0\u3002
\n\u867d\u7136 Linux \u4e0e UNIX \u4e00\u6837\uff0c\u53ef\u4ee5\u652f\u6301\u591a\u79cdShell\uff0c\u4f46BourneShell\u7684\u91cd\u8981\u5730\u4f4d\u81f3\u4eca\u4ecd\u7136\u6ca1\u6709\u6539\u53d8\uff0c\u8bb8\u591a UNIX \u7cfb\u7edf\u4e2d\u4ecd\u7136\u4f7f\u7528sh\u4f5c\u4e3a\u91cd\u8981\u7684\u7ba1\u7406\u5de5\u5177\u3002\u5b83\u7684\u5de5\u4f5c\u4ece\u5f00\u673a\u5230\u5173\u673a\uff0c\u51e0\u4e4e\u65e0\u6240\u4e0d\u5305\u3002\u5728Linux\u4e2d\uff0c\u7528\u6237Shell\u4e3b\u8981\u662f Bash\uff0c\u4f46\u5728\u542f\u52a8\u811a\u672c\u3001\u7f16\u8f91\u7b49\u5f88\u591a\u5de5\u4f5c\u4e2d\u4ecd\u7136\u4f7f\u7528BourneShell\u3002
\nCShell\u662f\u5e7f\u4e3a\u6d41\u884c\u7684Shell\u53d8\u79cd\u3002CShell\u4e3b\u8981\u5728 BSD \u7248\u7684 UNIX\u7cfb\u7edf\u4e2d\u4f7f\u7528\uff0c\u53d1\u660e\u8005\u662f\u67cf\u514b\u83b1\u5927\u5b66\u7684Bill Joy\u3002CShell\u56e0\u4e3a\u5176\u8bed\u6cd5\u548cC\u8bed\u8a00\u7c7b\u4f3c\u800c\u5f97\u540d\uff0c\u8fd9\u4e5f\u4f7f\u5f97UNIX\u7684\u7cfb\u7edf\u5de5\u7a0b\u5e08\u5728\u5b66\u4e60CShell\u65f6\u611f\u5230\u76f8\u5f53\u65b9\u4fbf\u3002
\nBashShell\u4e5f\u5c31\u662fBourne Again (Bash)\uff0c \u662f GNU \u8ba1\u5212\u7684\u91cd\u8981\u5de5\u5177\u4e4b\u4e00\uff0c\u4e5f\u662f GNU \u7cfb\u7edf\u4e2d\u6807\u51c6\u7684Shell\u3002Bash \u4e0e sh \u517c\u5bb9\uff0c\u6240\u4ee5\u8bb8\u591a\u65e9\u671f\u5f00\u53d1\u51fa\u6765\u7684 BourneShell\u7a0b\u5e8f\u90fd\u53ef\u4ee5\u7ee7\u7eed\u5728 Bash \u4e2d\u8fd0\u884c\u3002\u73b0\u5728\u4f7f\u7528\u7684 Linux \u5c31\u4f7f\u7528 Bash \u4f5c\u4e3a\u7528\u6237\u7684\u57fa\u672cShell\u3002
\nBash \u4e8e 1988 \u5e74\u53d1\u5e03\uff0c\u5e76\u5728 1995-1996\u5e74\u63a8\u51faBash 2.0\u3002\u5728\u8fd9\u4e4b\u524d\uff0c\u5e7f\u4e3a\u4f7f\u7528\u7684\u7248\u672c\u662f1.14\uff0cBash 2.0\u589e\u52a0\u4e86\u8bb8\u591a\u65b0\u7684\u529f\u80fd\uff0c\u4ee5\u53ca\u5177\u5907\u66f4\u597d\u7684\u517c\u5bb9\u6027\u3002
\n\u603b\u7ed3\uff1a<\/p>\n

Shell\u7684\u4e24\u79cd\u4e3b\u8981\u8bed\u6cd5\u7c7b\u578b\u6709Bourne\u548cC\uff0c\u8fd9\u4e24\u79cd\u8bed\u6cd5\u5f7c\u6b64\u4e0d\u517c\u5bb9\u3002Bourne\u5bb6\u65cf\u4e3b\u8981\u5305\u62ecsh\u3001ksh\u3001Bash\u3001psh\u3001zsh\uff1bC\u5bb6\u65cf\u4e3b\u8981\u5305\u62ec\uff1acsh\u3001tcsh\uff08Bash\u548czsh\u5728\u4e0d\u540c\u7a0b\u5ea6\u4e0a\u652f\u6301csh\u7684\u8bed\u6cd5\uff09\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Shell\u9664\u4e86\u80fd\u89e3\u91ca\u7528\u6237\u8f93\u5165\u7684\u547d\u4ee4\uff0c\u5c06\u5b83\u4f20\u9012\u7ed9\u5185\u6838\uff0c\u8fd8\u53ef\u4ee5\uff1a \u8c03\u7528\u5176\u4ed6\u7a0b\u5e8f\uff0c\u7ed9\u5176\u4ed6\u7a0b\u5e8f\u4f20\u9012\u6570\u636e\u6216\u53c2\u6570\uff0c\u5e76\u83b7\u53d6\u7a0b […]<\/p>\n","protected":false},"author":1903,"featured_media":233110,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-233096","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/233096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1903"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=233096"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/233096\/revisions"}],"predecessor-version":[{"id":233100,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/233096\/revisions\/233100"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/233110"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=233096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=233096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=233096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}