{"id":10657,"date":"2025-04-18T18:07:44","date_gmt":"2025-04-18T10:07:44","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/10657.html"},"modified":"2025-04-18T18:07:44","modified_gmt":"2025-04-18T10:07:44","slug":"shell%e7%bc%96%e7%a8%8b%e5%ad%a6%e4%b9%a0%e8%b7%af%e7%ba%bf-shell%e8%84%9a%e6%9c%ac%e4%b8%adcase%e8%af%ad%e5%8f%a5%e5%a4%9a%e5%88%86%e6%94%af%e9%80%89%e6%8b%a9%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/10657.html","title":{"rendered":"[Shell\u7f16\u7a0b\u5b66\u4e60\u8def\u7ebf]\u2014\u2014shell\u811a\u672c\u4e2dcase\u8bed\u53e5\u591a\u5206\u652f\u9009\u62e9\u8be6\u89e3"},"content":{"rendered":"<p style=\"text-align:center\">\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"80\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418100742-6802246e1a8f4.gif\" width=\"640\" \/><\/p>\n<p style=\"text-align:center\">&#x1f3e1;\u4f5c\u8005\u4e3b\u9875&#xff1a;\u70b9\u51fb&#xff01;\u00a0<\/p>\n<p style=\"text-align:center\">&#x1f6e0;\ufe0fShell\u7f16\u7a0b\u4e13\u680f&#xff1a;\u70b9\u51fb&#xff01;<\/p>\n<p style=\"text-align:center\">\u23f0\ufe0f\u521b\u4f5c\u65f6\u95f4&#xff1a;2024\u5e746\u670821\u65e516\u70b930\u5206<\/p>\n<p style=\"text-align:center\">&#x1f004;\ufe0f\u6587\u7ae0\u8d28\u91cf&#xff1a;95\u5206<\/p>\n<p style=\"text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"80\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418100742-6802246e1a8f4.gif\" width=\"640\" \/><\/p>\n<hr \/>\n<h3 style=\"background-color:transparent;text-align:center\">\u2014\u2014\u2014\u2014\u524d\u8a00\u2014\u2014\u2014\u2014<\/h3>\n<p>\u5728Shell\u7f16\u7a0b\u4e2d&#xff0c;\u5904\u7406\u591a\u79cd\u6761\u4ef6\u5224\u65ad\u548c\u9009\u62e9\u662f\u7f16\u5199\u811a\u672c\u65f6\u7ecf\u5e38\u9047\u5230\u7684\u9700\u6c42\u3002\u867d\u7136if-else\u8bed\u53e5\u53ef\u4ee5\u5b9e\u73b0\u6761\u4ef6\u5206\u652f&#xff0c;\u4f46\u5f53\u6761\u4ef6\u8f83\u591a\u65f6&#xff0c;\u4ee3\u7801\u4f1a\u53d8\u5f97\u7e41\u7410\u4e14\u4e0d\u6613\u7ef4\u62a4\u3002<\/p>\n<p>\u6b64\u65f6&#xff0c;case\u8bed\u53e5\u4f5c\u4e3a\u4e00\u79cd\u5f3a\u5927\u7684\u591a\u5206\u652f\u9009\u62e9\u5de5\u5177&#xff0c;\u63d0\u4f9b\u4e86\u66f4\u52a0\u7b80\u6d01\u548c\u9ad8\u6548\u7684\u89e3\u51b3\u65b9\u6848\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u8be6\u7ec6\u4ecb\u7ecdShell\u7f16\u7a0b\u4e2d\u7684case\u8bed\u53e5&#xff0c;\u5e2e\u52a9\u4f60\u638c\u63e1\u5176\u57fa\u672c\u8bed\u6cd5\u3001\u5e94\u7528\u573a\u666f\u53ca\u6ce8\u610f\u4e8b\u9879&#xff0c;<span style=\"background-color:#fbd4d0\">\u4ece\u800c\u63d0\u5347\u811a\u672c\u7f16\u5199\u7684\u7075\u6d3b\u6027\u548c\u53ef\u8bfb\u6027\u3002<\/span><\/p>\n<\/p>\n<p>\u65e0\u8bba\u4f60\u662fShell\u7f16\u7a0b\u7684\u65b0\u624b&#xff0c;\u8fd8\u662f\u6709\u4e00\u5b9a\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005&#xff0c;\u76f8\u4fe1\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\u7684\u5b66\u4e60&#xff0c;\u4f60\u90fd\u80fd\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u66f4\u597d\u5730\u8fd0\u7528case\u8bed\u53e5\u3002<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">case \u8bed\u53e5\u662fShell\u811a\u672c\u4e2d\u7684\u591a\u8def\u5206\u652f\u7ed3\u6784&#xff0c;\u7c7b\u4f3c\u4e8e\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u4e2d\u7684 switch \u8bed\u53e5\u3002\u5b83\u7528\u4e8e\u6839\u636e\u53d8\u91cf\u7684\u503c \u6267\u884c\u4e0d\u540c\u7684\u547d\u4ee4\u3002 case \u8bed\u53e5\u5728\u5904\u7406\u591a\u91cd\u6761\u4ef6\u5224\u65ad\u65f6\u975e\u5e38\u6709\u7528&#xff0c;\u4f7f\u4ee3\u7801\u66f4\u6e05\u6670\u548c\u6613\u8bfb\u3002<\/span><\/span><\/p>\n<\/p>\n<h4>\u57fa\u672c\u8bed\u6cd5<\/h4>\n<p>case \u503c in<br \/>\n\u6a21\u5f0f1)<br \/>\n    \u547d\u4ee41<br \/>\n    \u547d\u4ee42<br \/>\n    ;;<br \/>\n\u6a21\u5f0f2)<br \/>\n    \u547d\u4ee41<br \/>\n    \u547d\u4ee42<br \/>\n    ;;<br \/>\n*)<br \/>\n    \u9ed8\u8ba4\u547d\u4ee4<br \/>\n    ;;<br \/>\nesac <\/p>\n<p>\u8be6\u7ec6\u89e3\u91ca<\/p>\n<ul>\n<li>\u503c&#xff1a;\u9700\u8981\u5339\u914d\u7684\u53d8\u91cf\u6216\u5e38\u91cf\u3002<\/li>\n<li>\u6a21\u5f0f1, \u6a21\u5f0f2&#xff1a;\u7528\u4e8e\u5339\u914d\u503c\u7684\u6a21\u5f0f&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u901a\u914d\u7b26&#xff08;\u5982*\u3001?\u3001[ ]\u7b49&#xff09;\u3002<\/li>\n<li>\u547d\u4ee4&#xff1a;\u5f53\u6a21\u5f0f\u5339\u914d\u65f6\u6267\u884c\u7684\u547d\u4ee4\u3002<\/li>\n<li>;;&#xff1a;\u8868\u793a\u6a21\u5f0f\u7684\u7ed3\u675f&#xff0c;\u7c7b\u4f3c\u4e8eC\u8bed\u8a00\u4e2d\u7684break\u3002<\/li>\n<li>*&#xff1a;\u9ed8\u8ba4\u6a21\u5f0f&#xff0c;\u5f53\u6240\u6709\u6a21\u5f0f\u90fd\u4e0d\u5339\u914d\u65f6\u6267\u884c\u7684\u547d\u4ee4\u3002<\/li>\n<li>esac&#xff1a;\u8868\u793acase\u8bed\u53e5\u7684\u7ed3\u675f\u3002<\/li>\n<\/ul>\n<h4>\u793a\u4f8b<\/h4>\n<h5>\u7b80\u5355\u793a\u4f8b<\/h5>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d&#xff0c;\u7528\u6237\u8f93\u5165\u4e00\u4e2a\u6570\u5b57&#xff0c;case\u8bed\u53e5\u4f1a\u6839\u636e\u8f93\u5165\u7684\u6570\u5b57\u8fdb\u884c\u5339\u914d&#xff0c;\u5e76\u6267\u884c\u76f8\u5e94\u7684\u547d\u4ee4\u3002<\/p>\n<p>sh<br \/>\n\u590d\u5236\u4ee3\u7801<br \/>\n#!\/bin\/bash<\/p>\n<p>echo &#034;\u8bf7\u8f93\u5165\u4e00\u4e2a\u6570\u5b57&#xff1a;&#034;<br \/>\nread number<\/p>\n<p>case $number in<br \/>\n1)<br \/>\n    echo &#034;\u4f60\u8f93\u5165\u7684\u662f 1&#034;<br \/>\n    ;;<br \/>\n2)<br \/>\n    echo &#034;\u4f60\u8f93\u5165\u7684\u662f 2&#034;<br \/>\n    ;;<br \/>\n3)<br \/>\n    echo &#034;\u4f60\u8f93\u5165\u7684\u662f 3&#034;<br \/>\n    ;;<br \/>\n*)<br \/>\n    echo &#034;\u4f60\u8f93\u5165\u7684\u662f\u5176\u4ed6\u6570\u5b57&#034;<br \/>\n    ;;<br \/>\nesac <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1080\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418100742-6802246e27252.jpg\" width=\"1200\" \/><\/p>\n<\/p>\n<h5>\u4f7f\u7528\u901a\u914d\u7b26<\/h5>\n<p>\u8fd9\u4e2a\u793a\u4f8b\u6839\u636e\u6587\u4ef6\u6269\u5c55\u540d\u6765\u5224\u65ad\u6587\u4ef6\u7c7b\u578b\u3002*.txt\u5339\u914d\u6240\u6709\u4ee5.txt\u7ed3\u5c3e\u7684\u6587\u4ef6\u540d&#xff0c;*.jpg|*.png\u5339\u914d\u6240\u6709\u4ee5.jpg\u6216.png\u7ed3\u5c3e\u7684\u6587\u4ef6\u540d\u3002<\/p>\n<p>sh<br \/>\n\u590d\u5236\u4ee3\u7801<br \/>\n#!\/bin\/bash<\/p>\n<p>echo &#034;\u8bf7\u8f93\u5165\u4e00\u4e2a\u6587\u4ef6\u540d&#xff1a;&#034;<br \/>\nread filename<\/p>\n<p>case $filename in<br \/>\n*.txt)<br \/>\n    echo &#034;\u8fd9\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6&#034;<br \/>\n    ;;<br \/>\n*.jpg|*.png)<br \/>\n    echo &#034;\u8fd9\u662f\u4e00\u4e2a\u56fe\u7247\u6587\u4ef6&#034;<br \/>\n    ;;<br \/>\n*)<br \/>\n    echo &#034;\u8fd9\u662f\u5176\u4ed6\u7c7b\u578b\u7684\u6587\u4ef6&#034;<br \/>\n    ;;<br \/>\nesac <\/p>\n<h5>\u5339\u914d\u591a\u4e2a\u6761\u4ef6<\/h5>\n<p>\u8fd9\u4e2a\u793a\u4f8b\u6839\u636e\u7528\u6237\u8f93\u5165\u7684\u5b57\u7b26\u7c7b\u578b\u8fdb\u884c\u5206\u7c7b\u3002[a-z]\u5339\u914d\u6240\u6709\u5c0f\u5199\u5b57\u6bcd&#xff0c;[A-Z]\u5339\u914d\u6240\u6709\u5927\u5199\u5b57\u6bcd&#xff0c;[0-9]\u5339\u914d\u6240\u6709\u6570\u5b57\u3002<\/p>\n<p>sh<br \/>\n\u590d\u5236\u4ee3\u7801<br \/>\n#!\/bin\/bash<\/p>\n<p>echo &#034;\u8bf7\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26&#xff1a;&#034;<br \/>\nread char<\/p>\n<p>case $char in<br \/>\n[a-z])<br \/>\n    echo &#034;\u4f60\u8f93\u5165\u7684\u662f\u4e00\u4e2a\u5c0f\u5199\u5b57\u6bcd&#034;<br \/>\n    ;;<br \/>\n[A-Z])<br \/>\n    echo &#034;\u4f60\u8f93\u5165\u7684\u662f\u4e00\u4e2a\u5927\u5199\u5b57\u6bcd&#034;<br \/>\n    ;;<br \/>\n[0-9])<br \/>\n    echo &#034;\u4f60\u8f93\u5165\u7684\u662f\u4e00\u4e2a\u6570\u5b57&#034;<br \/>\n    ;;<br \/>\n*)<br \/>\n    echo &#034;\u4f60\u8f93\u5165\u7684\u662f\u5176\u4ed6\u5b57\u7b26&#034;<br \/>\n    ;;<br \/>\nesac <\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1080\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418100742-6802246ea824e.jpg\" width=\"1200\" \/><\/p>\n<h5>\u68c0\u6d4b\u8f93\u5165<\/h5>\n<p>\u7f16\u5199\u811a\u672c<\/p>\n<p>\u68c0\u67e5\u7528\u6237\u8f93\u5165\u7684\u5b57\u7b26\u7c7b\u578b\u63d0\u793a\u7528\u6237\u4ece\u952e\u76d8\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26,\u901a\u8fc7 case \u8bed\u53e5\u5224\u65ad\u8be5\u5b57\u7b26\u662f\u5426\u4e3a\u5b57\u6bcd,\u6570\u5b57 \u6216\u8005\u5176\u4ed6\u63a7\u5236\u5b57\u7b26\u5e76\u7ed9\u51fa\u76f8\u5e94\u7684\u63d0\u793a\u4fe1\u606f\u3002<\/p>\n<p>vim case.sh<br \/>\n#!\/bin\/bash<br \/>\nread -p &#034;\u8bf7\u4f60\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26:&#034; key<br \/>\ncase $key in<br \/>\n[a-z] |[A-Z])<br \/>\necho &#034;\u4f60\u8f93\u5165\u7684\u662f\u5b57\u6bcd$key&#034;<br \/>\n;;<br \/>\n[0-9])<br \/>\necho &#034;\u4f60\u8f93\u5165\u7684\u662f\u6570\u5b57 $key&#034;<br \/>\n;;<br \/>\n*) echo &#034;\u4f60\u8f93\u5165\u7684\u662f\u5176\u4ed6\u5b57\u7b26&#034;<br \/>\nesac<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"485\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418100743-6802246f3302f.png\" width=\"893\" \/><\/p>\n<\/p>\n<h3 style=\"background-color:transparent\">\u603b\u7ed3<\/h3>\n<p>case\u8bed\u53e5\u5728Shell\u7f16\u7a0b\u4e2d\u662f\u4e00\u79cd\u7b80\u6d01\u9ad8\u6548\u7684\u591a\u5206\u652f\u9009\u62e9\u5de5\u5177\u3002\u672c\u6587\u4ecb\u7ecd\u4e86\u5176\u57fa\u672c\u8bed\u6cd5\u3001\u901a\u914d\u7b26\u4f7f\u7528\u548c\u591a\u6761\u4ef6\u5339\u914d\u65b9\u5f0f&#xff0c;\u5e76\u63a2\u8ba8\u4e86\u5728\u7528\u6237\u8f93\u5165\u5904\u7406\u3001\u6587\u4ef6\u5904\u7406\u548c\u670d\u52a1\u811a\u672c\u4e2d\u7684\u5e94\u7528\u3002\u76f8\u6bd4\u7e41\u7410\u7684if-else&#xff0c;case\u8bed\u53e5\u4f7f\u4ee3\u7801\u66f4\u5177\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\u3002\u901a\u8fc7\u638c\u63e1case\u8bed\u53e5&#xff0c;\u4f60\u53ef\u4ee5\u7f16\u5199\u51fa\u66f4\u7b80\u6d01\u3001\u4f18\u96c5\u548c\u9ad8\u6548\u7684Shell\u811a\u672c&#xff0c;\u63d0\u5347\u7f16\u7a0b\u6548\u7387\u548c\u6027\u80fd\u3002<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">\u5e0c\u671b\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\u7684\u5b66\u4e60&#xff0c;\u4f60\u80fd\u5728Shell\u7f16\u7a0b\u4e2d\u719f\u7ec3\u8fd0\u7528<\/span><span style=\"background-color:#fbd4d0\">case<\/span><span style=\"background-color:#fbd4d0\">\u8bed\u53e5&#xff0c;\u7f16\u5199\u51fa\u66f4\u52a0\u7b80\u6d01\u3001\u4f18\u96c5\u548c\u9ad8\u6548\u7684\u811a\u672c&#xff0c;\u4e3a\u4f60\u7684\u5f00\u53d1\u5de5\u4f5c\u63d0\u4f9b\u6709\u529b\u7684\u652f\u6301\u3002<\/span><\/span>\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005&#xff0c;\u638c\u63e1case\u8bed\u53e5\u90fd\u662fShell\u7f16\u7a0b\u6280\u80fd\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002<\/p>\n<\/p>\n<p><span style=\"color:#fe2c24\"><span style=\"background-color:#fbd4d0\">\u00a0&#034;\u6210\u529f\u7684\u8def\u4e0a\u6ca1\u6709\u6377\u5f84&#xff0c;\u53ea\u6709\u4e0d\u65ad\u7684\u52aa\u529b\u4e0e\u575a\u6301\u3002\u5982\u679c\u4f60\u548c\u6211\u4e00\u6837&#xff0c;\u575a\u4fe1\u52aa\u529b\u4f1a\u5e26\u6765\u56de\u62a5&#xff0c;\u8bf7\u5173\u6ce8\u6211&#xff0c;\u70b9\u4e2a\u8d5e&#xff0c;\u4e00\u8d77\u8fce\u63a5\u66f4\u52a0\u7f8e\u597d\u7684\u660e\u5929&#xff01;\u4f60\u7684\u652f\u6301\u662f\u6211\u7ee7\u7eed\u524d\u884c\u7684\u52a8\u529b&#xff01;&#034;<\/span><\/span><\/p>\n<\/p>\n<p>&#034;\u6bcf\u4e00\u6b21\u521b\u4f5c\u90fd\u662f\u4e00\u6b21\u5b66\u4e60\u7684\u8fc7\u7a0b&#xff0c;\u6587\u7ae0\u4e2d\u82e5\u6709\u4e0d\u8db3\u4e4b\u5904&#xff0c;\u8fd8\u8bf7\u5927\u5bb6\u591a\u591a\u5305\u5bb9\u3002\u4f60\u7684\u5173\u6ce8\u548c\u70b9\u8d5e\u662f\u5bf9\u6211\u6700\u5927\u7684\u652f\u6301&#xff0c;\u4e5f\u6b22\u8fce\u5927\u5bb6\u63d0\u51fa\u5b9d\u8d35\u7684\u610f\u89c1\u548c\u5efa\u8bae&#xff0c;\u8ba9\u6211\u4e0d\u65ad\u8fdb\u6b65\u3002&#034;<\/p>\n<\/p>\n<p style=\"text-align:center\">\u795e\u79d8\u6ce3\u7537\u5b50<\/p>\n<p style=\"text-align:center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"289\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418100743-6802246f573fc.png\" width=\"296\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.8k\u6b21\uff0c\u70b9\u8d5e74\u6b21\uff0c\u6536\u85cf80\u6b21\u3002\u5728Shell\u7f16\u7a0b\u4e2d\uff0c\u5904\u7406\u591a\u79cd\u6761\u4ef6\u5224\u65ad\u548c\u9009\u62e9\u662f\u7f16\u5199\u811a\u672c\u65f6\u7ecf\u5e38\u9047\u5230\u7684\u9700\u6c42\u3002\u867d\u7136if-else\u8bed\u53e5\u53ef\u4ee5\u5b9e\u73b0\u6761\u4ef6\u5206\u652f\uff0c\u4f46\u5f53\u6761\u4ef6\u8f83\u591a\u65f6\uff0c\u4ee3\u7801\u4f1a\u53d8\u5f97\u7e41\u7410\u4e14\u4e0d\u6613\u7ef4\u62a4\u3002\u6b64\u65f6\uff0ccase\u8bed\u53e5\u4f5c\u4e3a\u4e00\u79cd\u5f3a\u5927\u7684\u591a\u5206\u652f\u9009\u62e9\u5de5\u5177\uff0c\u63d0\u4f9b\u4e86\u66f4\u52a0\u7b80\u6d01\u548c\u9ad8\u6548\u7684\u89e3\u51b3\u65b9\u6848\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u8be6\u7ec6\u4ecb\u7ecdShell\u7f16\u7a0b\u4e2d\u7684case\u8bed\u53e5\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u5176\u57fa\u672c\u8bed\u6cd5\u3001\u5e94\u7528\u573a\u666f\u53ca\u6ce8\u610f\u4e8b\u9879\uff0c\u4ece\u800c\u63d0\u5347\u811a\u672c\u7f16\u5199\u7684\u7075\u6d3b\u6027\u548c\u53ef\u8bfb\u6027\u3002\u65e0\u8bba\u4f60\u662fShell\u7f16\u7a0b\u7684\u65b0\u624b\uff0c\u8fd8\u662f\u6709\u4e00\u5b9a\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u76f8\u4fe1\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\u7684\u5b66\u4e60\uff0c\u4f60\u90fd\u80fd\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u66f4\u597d\u5730\u8fd0\u7528case\u8bed\u53e5\u3002_shell\u7f16\u7a0b case<\/p>\n","protected":false},"author":2,"featured_media":10652,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[59,58,466,371,43,395,44],"topic":[],"class_list":["post-10657","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-centos","tag-linux","tag-shell","tag-371","tag-43","tag-395","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Shell\u7f16\u7a0b\u5b66\u4e60\u8def\u7ebf]\u2014\u2014shell\u811a\u672c\u4e2dcase\u8bed\u53e5\u591a\u5206\u652f\u9009\u62e9\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/10657.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Shell\u7f16\u7a0b\u5b66\u4e60\u8def\u7ebf]\u2014\u2014shell\u811a\u672c\u4e2dcase\u8bed\u53e5\u591a\u5206\u652f\u9009\u62e9\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.8k\u6b21\uff0c\u70b9\u8d5e74\u6b21\uff0c\u6536\u85cf80\u6b21\u3002\u5728Shell\u7f16\u7a0b\u4e2d\uff0c\u5904\u7406\u591a\u79cd\u6761\u4ef6\u5224\u65ad\u548c\u9009\u62e9\u662f\u7f16\u5199\u811a\u672c\u65f6\u7ecf\u5e38\u9047\u5230\u7684\u9700\u6c42\u3002\u867d\u7136if-else\u8bed\u53e5\u53ef\u4ee5\u5b9e\u73b0\u6761\u4ef6\u5206\u652f\uff0c\u4f46\u5f53\u6761\u4ef6\u8f83\u591a\u65f6\uff0c\u4ee3\u7801\u4f1a\u53d8\u5f97\u7e41\u7410\u4e14\u4e0d\u6613\u7ef4\u62a4\u3002\u6b64\u65f6\uff0ccase\u8bed\u53e5\u4f5c\u4e3a\u4e00\u79cd\u5f3a\u5927\u7684\u591a\u5206\u652f\u9009\u62e9\u5de5\u5177\uff0c\u63d0\u4f9b\u4e86\u66f4\u52a0\u7b80\u6d01\u548c\u9ad8\u6548\u7684\u89e3\u51b3\u65b9\u6848\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u8be6\u7ec6\u4ecb\u7ecdShell\u7f16\u7a0b\u4e2d\u7684case\u8bed\u53e5\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u5176\u57fa\u672c\u8bed\u6cd5\u3001\u5e94\u7528\u573a\u666f\u53ca\u6ce8\u610f\u4e8b\u9879\uff0c\u4ece\u800c\u63d0\u5347\u811a\u672c\u7f16\u5199\u7684\u7075\u6d3b\u6027\u548c\u53ef\u8bfb\u6027\u3002\u65e0\u8bba\u4f60\u662fShell\u7f16\u7a0b\u7684\u65b0\u624b\uff0c\u8fd8\u662f\u6709\u4e00\u5b9a\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u76f8\u4fe1\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\u7684\u5b66\u4e60\uff0c\u4f60\u90fd\u80fd\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u66f4\u597d\u5730\u8fd0\u7528case\u8bed\u53e5\u3002_shell\u7f16\u7a0b case\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/10657.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T10:07:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418100742-6802246e1a8f4.gif\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/10657.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/10657.html\",\"name\":\"[Shell\u7f16\u7a0b\u5b66\u4e60\u8def\u7ebf]\u2014\u2014shell\u811a\u672c\u4e2dcase\u8bed\u53e5\u591a\u5206\u652f\u9009\u62e9\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T10:07:44+00:00\",\"dateModified\":\"2025-04-18T10:07:44+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/10657.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/10657.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/10657.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Shell\u7f16\u7a0b\u5b66\u4e60\u8def\u7ebf]\u2014\u2014shell\u811a\u672c\u4e2dcase\u8bed\u53e5\u591a\u5206\u652f\u9009\u62e9\u8be6\u89e3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Shell\u7f16\u7a0b\u5b66\u4e60\u8def\u7ebf]\u2014\u2014shell\u811a\u672c\u4e2dcase\u8bed\u53e5\u591a\u5206\u652f\u9009\u62e9\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/10657.html","og_locale":"zh_CN","og_type":"article","og_title":"[Shell\u7f16\u7a0b\u5b66\u4e60\u8def\u7ebf]\u2014\u2014shell\u811a\u672c\u4e2dcase\u8bed\u53e5\u591a\u5206\u652f\u9009\u62e9\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.8k\u6b21\uff0c\u70b9\u8d5e74\u6b21\uff0c\u6536\u85cf80\u6b21\u3002\u5728Shell\u7f16\u7a0b\u4e2d\uff0c\u5904\u7406\u591a\u79cd\u6761\u4ef6\u5224\u65ad\u548c\u9009\u62e9\u662f\u7f16\u5199\u811a\u672c\u65f6\u7ecf\u5e38\u9047\u5230\u7684\u9700\u6c42\u3002\u867d\u7136if-else\u8bed\u53e5\u53ef\u4ee5\u5b9e\u73b0\u6761\u4ef6\u5206\u652f\uff0c\u4f46\u5f53\u6761\u4ef6\u8f83\u591a\u65f6\uff0c\u4ee3\u7801\u4f1a\u53d8\u5f97\u7e41\u7410\u4e14\u4e0d\u6613\u7ef4\u62a4\u3002\u6b64\u65f6\uff0ccase\u8bed\u53e5\u4f5c\u4e3a\u4e00\u79cd\u5f3a\u5927\u7684\u591a\u5206\u652f\u9009\u62e9\u5de5\u5177\uff0c\u63d0\u4f9b\u4e86\u66f4\u52a0\u7b80\u6d01\u548c\u9ad8\u6548\u7684\u89e3\u51b3\u65b9\u6848\u3002\u672c\u7bc7\u6587\u7ae0\u5c06\u8be6\u7ec6\u4ecb\u7ecdShell\u7f16\u7a0b\u4e2d\u7684case\u8bed\u53e5\uff0c\u5e2e\u52a9\u4f60\u638c\u63e1\u5176\u57fa\u672c\u8bed\u6cd5\u3001\u5e94\u7528\u573a\u666f\u53ca\u6ce8\u610f\u4e8b\u9879\uff0c\u4ece\u800c\u63d0\u5347\u811a\u672c\u7f16\u5199\u7684\u7075\u6d3b\u6027\u548c\u53ef\u8bfb\u6027\u3002\u65e0\u8bba\u4f60\u662fShell\u7f16\u7a0b\u7684\u65b0\u624b\uff0c\u8fd8\u662f\u6709\u4e00\u5b9a\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u76f8\u4fe1\u901a\u8fc7\u672c\u7bc7\u6587\u7ae0\u7684\u5b66\u4e60\uff0c\u4f60\u90fd\u80fd\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u66f4\u597d\u5730\u8fd0\u7528case\u8bed\u53e5\u3002_shell\u7f16\u7a0b case","og_url":"https:\/\/www.wsisp.com\/helps\/10657.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T10:07:44+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418100742-6802246e1a8f4.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/10657.html","url":"https:\/\/www.wsisp.com\/helps\/10657.html","name":"[Shell\u7f16\u7a0b\u5b66\u4e60\u8def\u7ebf]\u2014\u2014shell\u811a\u672c\u4e2dcase\u8bed\u53e5\u591a\u5206\u652f\u9009\u62e9\u8be6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T10:07:44+00:00","dateModified":"2025-04-18T10:07:44+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/10657.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/10657.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/10657.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"[Shell\u7f16\u7a0b\u5b66\u4e60\u8def\u7ebf]\u2014\u2014shell\u811a\u672c\u4e2dcase\u8bed\u53e5\u591a\u5206\u652f\u9009\u62e9\u8be6\u89e3"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/10657","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=10657"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/10657\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/10652"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=10657"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=10657"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=10657"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=10657"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}