{"id":90380,"date":"2026-08-05T07:41:07","date_gmt":"2026-08-04T23:41:07","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/90380.html"},"modified":"2026-08-05T07:41:07","modified_gmt":"2026-08-04T23:41:07","slug":"linux%e8%bf%9b%e9%98%b6%e6%89%93%e6%80%aa%ef%bc%9ashell%e7%bc%96%e7%a8%8b%e4%bf%9d%e5%a7%86%e7%ba%a7%e5%85%a5%e9%97%a8%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/90380.html","title":{"rendered":"Linux\u8fdb\u9636\u6253\u602a\uff1aShell\u7f16\u7a0b\u4fdd\u59c6\u7ea7\u5165\u95e8\u6307\u5357"},"content":{"rendered":"<p>\u63d0\u793a&#xff1a;\u6587\u7ae0\u5199\u5b8c\u540e&#xff0c;\u76ee\u5f55\u53ef\u4ee5\u81ea\u52a8\u751f\u6210&#xff0c;\u5982\u4f55\u751f\u6210\u53ef\u53c2\u8003\u53f3\u8fb9\u7684\u5e2e\u52a9\u6587\u6863<\/p>\n<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u524d\u8a00<\/li>\n<li>\u4e00\u3001\u5148\u641e\u61c2&#xff1a;Shell\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;<\/li>\n<li>\n<ul>\n<li>\u7b2c\u4e00\u4e2aShell\u811a\u672c&#xff1a;Hello World<\/li>\n<li>\u811a\u672c\u7684\u4e24\u79cd\u6267\u884c\u65b9\u5f0f<\/li>\n<\/ul>\n<\/li>\n<li>\u4e8c\u3001Shell\u53d8\u91cf&#xff1a;\u65b0\u624b\u5751\u6700\u591a\u7684\u5730\u65b9<\/li>\n<li>\n<ul>\n<li>1. \u7cfb\u7edf\u81ea\u5e26\u7684\u53d8\u91cf<\/li>\n<li>2. \u81ea\u5b9a\u4e49\u53d8\u91cf&#xff1a;\u8bb0\u4f4f\u201c\u7b49\u53f7\u4e24\u8fb9\u6ca1\u7a7a\u683c\u201d<\/li>\n<li>3. \u73af\u5883\u53d8\u91cf&#xff1a;\u5168\u5c40\u751f\u6548\u7684\u53d8\u91cf<\/li>\n<li>4. \u4f4d\u7f6e\u53c2\u6570\u53d8\u91cf&#xff1a;\u7ed9\u811a\u672c\u4f20\u53c2\u6570<\/li>\n<li>5. \u9884\u5b9a\u4e49\u53d8\u91cf&#xff1a;Shell\u63d0\u524d\u5b9a\u4e49\u597d\u7684<\/li>\n<\/ul>\n<\/li>\n<li>\u4e09\u3001Shell\u8fd0\u7b97\u7b26&#xff1a;\u7b97\u6570\u8fd0\u7b97\u600e\u4e48\u5199<\/li>\n<li>\u56db\u3001\u6761\u4ef6\u5224\u65ad&#xff1a;\u903b\u8f91\u63a7\u5236\u7684\u57fa\u7840<\/li>\n<li>\n<ul>\n<li>\u57fa\u672c\u8bed\u6cd5<\/li>\n<li>\u5e38\u7528\u5224\u65ad\u6761\u4ef6<\/li>\n<li>\n<ul>\n<li>&#xff08;1&#xff09;\u5b57\u7b26\u4e32\u6bd4\u8f83<\/li>\n<li>&#xff08;2&#xff09;\u6574\u6570\u6bd4\u8f83<\/li>\n<li>&#xff08;3&#xff09;\u6587\u4ef6\u6743\u9650\u5224\u65ad<\/li>\n<li>&#xff08;4&#xff09;\u6587\u4ef6\u7c7b\u578b\u5224\u65ad<\/li>\n<\/ul>\n<\/li>\n<li>if\u5206\u652f\u8bed\u53e5<\/li>\n<li>case\u5206\u652f\u8bed\u53e5<\/li>\n<\/ul>\n<\/li>\n<li>\u4e94\u3001\u5faa\u73af\u8bed\u53e5&#xff1a;\u6279\u91cf\u64cd\u4f5c\u7684\u795e\u5668<\/li>\n<li>\n<ul>\n<li>1. for\u5faa\u73af<\/li>\n<li>\n<ul>\n<li>\u5199\u6cd51&#xff1a;\u904d\u5386\u53c2\u6570\/\u5217\u8868<\/li>\n<li>\u5199\u6cd52&#xff1a;\u7c7bC\u8bed\u8a00\u5faa\u73af<\/li>\n<\/ul>\n<\/li>\n<li>2. while\u5faa\u73af<\/li>\n<\/ul>\n<\/li>\n<li>\u516d\u3001read\u8bfb\u53d6\u8f93\u5165&#xff1a;\u8ba9\u811a\u672c\u53ef\u4ee5\u4ea4\u4e92<\/li>\n<li>\u4e03\u3001Shell\u51fd\u6570&#xff1a;\u5c01\u88c5\u590d\u7528\u4ee3\u7801<\/li>\n<li>\n<ul>\n<li>1. \u4e24\u4e2a\u8d85\u5b9e\u7528\u7684\u7cfb\u7edf\u51fd\u6570<\/li>\n<li>2. \u81ea\u5b9a\u4e49\u51fd\u6570<\/li>\n<\/ul>\n<\/li>\n<li>\u516b\u3001\u5b9e\u6218\u6848\u4f8b&#xff1a;MySQL\u5b9a\u65f6\u81ea\u52a8\u5907\u4efd<\/li>\n<li>\n<ul>\n<li>\u9700\u6c42<\/li>\n<li>\u811a\u672c\u5b9e\u73b0<\/li>\n<li>\u8bbe\u7f6e\u5b9a\u65f6\u6267\u884c<\/li>\n<\/ul>\n<\/li>\n<li>\u603b\u7ed3<\/li>\n<li>\n<ul>\n<li>1\u3001\u811a\u672c\u57fa\u7840<\/li>\n<li>2\u3001\u56db\u5927\u53d8\u91cf<\/li>\n<li>3\u3001\u7b97\u6570\u8fd0\u7b97<\/li>\n<li>4\u3001\u6761\u4ef6\u5224\u65ad<\/li>\n<li>\n<ul>\n<li>\u5206\u652f\u8bed\u53e5<\/li>\n<\/ul>\n<\/li>\n<li>5\u3001\u5faa\u73af<\/li>\n<li>6\u3001\u4ea4\u4e92\u8f93\u5165read<\/li>\n<li>7\u3001\u51fd\u6570<\/li>\n<li>8\u3001\u4f01\u4e1a\u5b9e\u6218&#xff1a;MySQL\u5b9a\u65f6\u5907\u4efd<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u524d\u8a00<\/h2>\n<p>\u8fd9\u7bc7\u535a\u5ba2\u6211\u5c31\u628aShell\u7f16\u7a0b\u4ece\u5165\u95e8\u5230\u5b9e\u6218\u7684\u6838\u5fc3\u5185\u5bb9\u5168\u90e8\u6574\u7406\u51fa\u6765&#xff0c;\u5305\u62ec\u65b0\u624b\u6700\u5bb9\u6613\u8e29\u7684\u8bed\u6cd5\u5751\u3001\u9ad8\u9891\u5fc5\u5b66\u7684\u8bed\u6cd5\u70b9\u3001\u8fd8\u6709\u4e00\u4e2a\u4f01\u4e1a\u91cc\u771f\u7684\u4f1a\u7528\u7684MySQL\u5b9a\u65f6\u5907\u4efd\u5b9e\u6218\u6848\u4f8b\u3002\u5168\u662f\u81ea\u5df1\u8e29\u5751\u603b\u7ed3\u51fa\u6765\u7684\u5e72\u8d27&#xff0c;\u5efa\u8bae\u6536\u85cf&#xff0c;\u5b66\u7684\u65f6\u5019\u5bf9\u7740\u6572\u4e00\u904d&#xff0c;\u57fa\u672c\u5c31\u80fd\u4e0a\u624b\u7528\u54e9<\/p>\n<h2>\u4e00\u3001\u5148\u641e\u61c2&#xff1a;Shell\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;<\/h2>\n<p>\u5f88\u591a\u4eba\u5b66\u4e86\u534a\u5929Shell&#xff0c;\u90fd\u6ca1\u641e\u660e\u767d\u5b83\u5230\u5e95\u662f\u5565\u3002\u5176\u5b9e\u4e00\u53e5\u8bdd\u5c31\u80fd\u8bf4\u6e05&#xff1a;Shell\u5c31\u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u89e3\u91ca\u5668&#xff0c;\u662f\u6211\u4eec\u548cLinux\u5185\u6838\u6c9f\u901a\u7684\u7ffb\u8bd1\u5b98\u3002<\/p>\n<p>\u6211\u4eec\u5728\u7ec8\u7aef\u6572\u7684cd\u3001ls\u8fd9\u4e9b\u547d\u4ee4&#xff0c;\u672c\u8d28\u4e0a\u90fd\u662f\u5148\u53d1\u7ed9Shell&#xff0c;\u518d\u7531Shell\u89e3\u6790\u540e\u8c03\u7528\u5185\u6838\u6267\u884c\u3002\u800cShell\u7f16\u7a0b&#xff0c;\u5c31\u662f\u628a\u4e00\u5806\u8981\u6267\u884c\u7684Linux\u547d\u4ee4&#xff0c;\u6309\u7167\u903b\u8f91\u987a\u5e8f\u5199\u8fdb\u4e00\u4e2a\u6587\u4ef6\u91cc&#xff0c;\u8ba9\u7cfb\u7edf\u81ea\u52a8\u6279\u91cf\u6267\u884c&#xff0c;\u4e0d\u7528\u6211\u4eec\u624b\u52a8\u4e00\u6761\u4e00\u6761\u6572\u3002<\/p>\n<p>Linux\u91cc\u6700\u5e38\u7528\u7684Shell\u5c31\u662fBash&#xff0c;\u4e5f\u662f\u6211\u4eec\u5b66\u4e60\u7684\u91cd\u70b9\u3002\u6211\u4eec\u5199\u7684\u811a\u672c\u6587\u4ef6\u901a\u5e38\u4ee5.sh\u7ed3\u5c3e&#xff0c;\u8fd9\u53ea\u662f\u4e2a\u7ea6\u5b9a\u4fd7\u6210\u7684\u6807\u8bc6&#xff0c;\u5176\u5b9e\u4e0d\u5f71\u54cd\u6267\u884c&#xff0c;\u4f46\u89c4\u8303\u8d77\u89c1\u8fd8\u662f\u5efa\u8bae\u52a0\u4e0a\u3002<\/p>\n<h3>\u7b2c\u4e00\u4e2aShell\u811a\u672c&#xff1a;Hello World<\/h3>\n<p>\u65b0\u624b\u5199\u7b2c\u4e00\u4e2a\u811a\u672c&#xff0c;\u5927\u6982\u7387\u4f1a\u8e29\u4e24\u4e2a\u5751&#xff1a;\u5fd8\u4e86\u52a0\u811a\u672c\u58f0\u660e\u3001\u5fd8\u4e86\u52a0\u6267\u884c\u6743\u9650\u3002\u6211\u5f53\u521d\u4e24\u4e2a\u5751\u5168\u8e29\u4e86&#xff0c;\u5370\u8c61\u6781\u5176\u6df1\u523b\u3002<\/p>\n<p>\u4e00\u4e2a\u6807\u51c6\u7684\u811a\u672c\u957f\u8fd9\u6837&#xff1a;<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token comment\"># \u6211\u7684\u7b2c\u4e00\u4e2aShell\u811a\u672c<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;Hello World!&#034;<\/span><\/p>\n<ul>\n<li>\u7b2c\u4e00\u884c#!\/bin\/bash\u662f\u5fc5\u987b\u7684&#xff0c;\u544a\u8bc9\u7cfb\u7edf\u8fd9\u4e2a\u811a\u672c\u8981\u7528Bash\u89e3\u91ca\u5668\u6765\u6267\u884c&#xff1b;<\/li>\n<li>#\u5f00\u5934\u7684\u662f\u6ce8\u91ca&#xff0c;\u811a\u672c\u8fd0\u884c\u7684\u65f6\u5019\u4f1a\u81ea\u52a8\u5ffd\u7565\u3002<\/li>\n<\/ul>\n<h3>\u811a\u672c\u7684\u4e24\u79cd\u6267\u884c\u65b9\u5f0f<\/h3>\n<li>\u8d4b\u4e88\u6743\u9650\u540e\u76f4\u63a5\u6267\u884c&#xff08;\u63a8\u8350&#xff09;<\/li>\n<p><span class=\"token comment\"># \u7ed9\u811a\u672c\u6dfb\u52a0\u53ef\u6267\u884c\u6743\u9650<\/span><br \/>\n<span class=\"token function\">chmod<\/span> u&#043;x hello.sh<br \/>\n<span class=\"token comment\"># \u76f8\u5bf9\u8def\u5f84\u6267\u884c<\/span><br \/>\n.\/hello.sh<br \/>\n<span class=\"token comment\"># \u4e5f\u53ef\u4ee5\u7528\u7edd\u5bf9\u8def\u5f84\u6267\u884c<\/span><br \/>\n\/root\/shellCode\/hello.sh<\/p>\n<li>\u7528sh\u547d\u4ee4\u76f4\u63a5\u8c03\u7528&#xff08;\u4e0d\u7528\u52a0\u6743\u9650&#xff09;<\/li>\n<p><span class=\"token function\">sh<\/span> hello.sh<\/p>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u672c\u8d28\u662f\u76f4\u63a5\u7528sh\u89e3\u91ca\u5668\u53bb\u8bfb\u6587\u4ef6&#xff0c;\u6240\u4ee5\u4e0d\u9700\u8981\u6587\u4ef6\u672c\u8eab\u6709\u6267\u884c\u6743\u9650&#xff0c;\u4e34\u65f6\u6d4b\u8bd5\u7684\u65f6\u5019\u5f88\u65b9\u4fbf\u3002<\/p>\n<h2>\u4e8c\u3001Shell\u53d8\u91cf&#xff1a;\u65b0\u624b\u5751\u6700\u591a\u7684\u5730\u65b9<\/h2>\n<p>Shell\u7684\u53d8\u91cf\u5206\u4e3a\u56db\u5927\u7c7b&#xff1a;\u7cfb\u7edf\u53d8\u91cf\u3001\u81ea\u5b9a\u4e49\u53d8\u91cf\u3001\u73af\u5883\u53d8\u91cf\u3001\u7279\u6b8a\u53d8\u91cf&#xff0c;\u5176\u4e2d\u7ec6\u8282\u7279\u522b\u591a&#xff0c;\u5c24\u5176\u662f\u7a7a\u683c\u89c4\u5219&#xff0c;\u65b0\u624b\u4e00\u4e0d\u6ce8\u610f\u5c31\u62a5\u9519\u3002<\/p>\n<h3>1. \u7cfb\u7edf\u81ea\u5e26\u7684\u53d8\u91cf<\/h3>\n<p>Linux\u5185\u7f6e\u4e86\u5f88\u591a\u73b0\u6210\u7684\u53d8\u91cf&#xff0c;\u6bd4\u5982$HOME&#xff08;\u5f53\u524d\u7528\u6237\u5bb6\u76ee\u5f55&#xff09;\u3001$PWD&#xff08;\u5f53\u524d\u6240\u5728\u7edd\u5bf9\u8def\u5f84&#xff09;\u3001$SHELL&#xff08;\u5f53\u524d\u89e3\u91ca\u5668&#xff09;\u3001$USER&#xff08;\u5f53\u524d\u7528\u6237\u540d&#xff09;\u3002 \u60f3\u67e5\u770b\u6240\u6709\u7cfb\u7edf\u53d8\u91cf&#xff0c;\u76f4\u63a5\u8f93set\u5c31\u884c&#xff0c;\u4f1a\u5217\u51fa\u5f53\u524dShell\u91cc\u6240\u6709\u7684\u53d8\u91cf\u548c\u51fd\u6570\u3002<\/p>\n<p>\u8fd0\u884c\u5b9e\u4f8b\u5982\u4e0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234105-6a727891cd73a.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>2. \u81ea\u5b9a\u4e49\u53d8\u91cf&#xff1a;\u8bb0\u4f4f\u201c\u7b49\u53f7\u4e24\u8fb9\u6ca1\u7a7a\u683c\u201d<\/h3>\n<p>\u8fd9\u662f\u6211\u8e29\u7684\u7b2c\u4e00\u4e2a\u5927\u5751&#xff01;\u5199A &#061; 100\u62a5\u9519\u4e86\u534a\u5929&#xff0c;\u540e\u6765\u624d\u77e5\u9053Shell\u91cc\u53d8\u91cf\u8d4b\u503c&#xff0c;\u7b49\u53f7\u5de6\u53f3\u7edd\u5bf9\u4e0d\u80fd\u6709\u7a7a\u683c\u3002<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token comment\"># \u6b63\u786e\u5199\u6cd5&#xff1a;\u7b49\u53f7\u4e24\u8fb9\u65e0\u7a7a\u683c<\/span><br \/>\n<span class=\"token assign-left variable\">A<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">100<\/span><br \/>\n<span class=\"token comment\"># \u8f93\u51fa\u53d8\u91cf\u8981\u52a0$\u7b26\u53f7<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token assign-left variable\">A<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\">$A<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;A&#061;<span class=\"token variable\">$A<\/span>&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u64a4\u9500\u53d8\u91cf\u7528unset<\/span><br \/>\n<span class=\"token builtin class-name\">unset<\/span> A<br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u64a4\u9500\u540eA&#061;<span class=\"token variable\">$A<\/span>&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u58f0\u660e\u53ea\u8bfb\u53d8\u91cf&#xff0c;\u4e0d\u80fd\u4fee\u6539\u4e5f\u4e0d\u80fd\u64a4\u9500<\/span><br \/>\n<span class=\"token builtin class-name\">readonly<\/span> <span class=\"token assign-left variable\">B<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">2<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u53ea\u8bfb\u53d8\u91cfB&#061;<span class=\"token variable\">$B<\/span>&#034;<\/span><\/p>\n<p>\u8fd8\u6709\u51e0\u4e2a\u547d\u540d\u89c4\u5219\u8981\u8bb0\u4f4f&#xff1a;<\/p>\n<ul>\n<li>\u53d8\u91cf\u540d\u53ea\u80fd\u7531\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u4e0b\u5212\u7ebf\u7ec4\u6210&#xff0c;\u4e0d\u80fd\u4ee5\u6570\u5b57\u5f00\u5934&#xff1b;<\/li>\n<li>\u53d8\u91cf\u540d\u4e60\u60ef\u5168\u5927\u5199&#xff0c;\u7b97\u662f\u884c\u4e1a\u9ed8\u8ba4\u89c4\u8303&#xff1b;<\/li>\n<li>\u60f3\u628a\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c\u8d4b\u503c\u7ed9\u53d8\u91cf&#xff0c;\u6709\u4e24\u79cd\u5199\u6cd5&#xff1a;<\/li>\n<\/ul>\n<p><span class=\"token comment\"># \u5199\u6cd51&#xff1a;\u53cd\u5f15\u53f7&#xff08;\u4e0d\u63a8\u8350&#xff0c;\u5bb9\u6613\u548c\u5355\u5f15\u53f7\u641e\u6df7&#xff09;<\/span><br \/>\n<span class=\"token assign-left variable\">C<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\"><span class=\"token variable\">&#096;<\/span><span class=\"token function\">date<\/span><span class=\"token variable\">&#096;<\/span><\/span><br \/>\n<span class=\"token comment\"># \u5199\u6cd52&#xff1a;$()&#xff08;\u63a8\u8350&#xff0c;\u6e05\u6670\u6613\u8bfb&#xff09;<\/span><br \/>\n<span class=\"token assign-left variable\">D<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">date<\/span><span class=\"token variable\">)<\/span><\/span><\/p>\n<h3>3. \u73af\u5883\u53d8\u91cf&#xff1a;\u5168\u5c40\u751f\u6548\u7684\u53d8\u91cf<\/h3>\n<p>\u5982\u679c\u60f3\u8ba9\u4e00\u4e2a\u53d8\u91cf\u5728\u6240\u6709Shell\u811a\u672c\u91cc\u90fd\u80fd\u7528&#xff0c;\u5c31\u8981\u628a\u5b83\u8bbe\u6210\u73af\u5883\u53d8\u91cf\u3002 \u6211\u4eec\u4e4b\u524d\u914d\u7f6eJDK\u7684\u65f6\u5019\u6539\u7684\/etc\/profile&#xff0c;\u91cc\u9762\u5199\u7684\u5c31\u662f\u5168\u5c40\u73af\u5883\u53d8\u91cf\u3002\u914d\u7f6e\u6b65\u9aa4\u5f88\u56fa\u5b9a&#xff1a;<\/p>\n<li>\u7528export \u53d8\u91cf\u540d&#061;\u53d8\u91cf\u503c\u628a\u53d8\u91cf\u5bfc\u51fa\u4e3a\u73af\u5883\u53d8\u91cf&#xff1b;<\/li>\n<li>\u6267\u884csource \u914d\u7f6e\u6587\u4ef6\u8ba9\u4fee\u6539\u7acb\u523b\u751f\u6548&#xff0c;\u4e0d\u7528\u91cd\u542f\u7cfb\u7edf&#xff1b;<\/li>\n<li>\u7528echo $\u53d8\u91cf\u540d\u5c31\u80fd\u67e5\u5230\u53d8\u91cf\u503c\u4e86\u3002<\/li>\n<h3>4. \u4f4d\u7f6e\u53c2\u6570\u53d8\u91cf&#xff1a;\u7ed9\u811a\u672c\u4f20\u53c2\u6570<\/h3>\n<p>\u6211\u4eec\u5199\u7684\u811a\u672c\u4e0d\u53ef\u80fd\u6c38\u8fdc\u5199\u6b7b\u5185\u5bb9&#xff0c;\u5f88\u591a\u65f6\u5019\u9700\u8981\u8fd0\u884c\u7684\u65f6\u5019\u4f20\u53c2\u6570\u8fdb\u53bb&#xff0c;\u8fd9\u65f6\u5019\u5c31\u8981\u7528\u5230\u4f4d\u7f6e\u53c2\u6570\u53d8\u91cf\u3002 \u5e38\u7528\u7684\u5c31\u8fd9\u51e0\u4e2a&#xff1a;<\/p>\n<table>\n<tr>\u53d8\u91cf\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>$0<\/td>\n<td>\u811a\u672c\u672c\u8eab\u7684\u6587\u4ef6\u540d<\/td>\n<\/tr>\n<tr>\n<td>$n<\/td>\n<td>\u7b2cn\u4e2a\u8f93\u5165\u53c2\u6570&#xff0c;n\u4ece1\u5f00\u59cb&#xff0c;10\u4ee5\u4e0a\u8981\u5199\u6210${10}<\/td>\n<\/tr>\n<tr>\n<td>$*<\/td>\n<td>\u6240\u6709\u8f93\u5165\u53c2\u6570&#xff0c;\u5f53\u6210\u4e00\u4e2a\u6574\u4f53\u770b\u5f85<\/td>\n<\/tr>\n<tr>\n<td>$&#064;<\/td>\n<td>\u6240\u6709\u8f93\u5165\u53c2\u6570&#xff0c;\u6bcf\u4e2a\u53c2\u6570\u76f8\u4e92\u72ec\u7acb<\/td>\n<\/tr>\n<tr>\n<td>$#<\/td>\n<td>\u8f93\u5165\u53c2\u6570\u7684\u603b\u4e2a\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\u5c31\u61c2\u4e86&#xff0c;\u5199\u4e2a\u811a\u672cposition.sh&#xff1a;<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u811a\u672c\u6587\u4ef6\u540d&#xff1a;<span class=\"token variable\">$0<\/span>&#034;<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u7b2c\u4e00\u4e2a\u53c2\u6570&#xff1a;<span class=\"token variable\">$1<\/span>&#034;<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u7b2c\u4e8c\u4e2a\u53c2\u6570&#xff1a;<span class=\"token variable\">$2<\/span>&#034;<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u6240\u6709\u53c2\u6570(\u6574\u4f53)&#xff1a;<span class=\"token variable\">$*<\/span>&#034;<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u6240\u6709\u53c2\u6570(\u72ec\u7acb)&#xff1a;<span class=\"token variable\">$&#064;<\/span>&#034;<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u53c2\u6570\u603b\u4e2a\u6570&#xff1a;<span class=\"token variable\">$#<\/span>&#034;<\/span><\/p>\n<p>\u8fd0\u884c\u5b9e\u4f8b\u5982\u4e0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234105-6a727891f0627.png\" alt=\"\" \/><\/p>\n<p>\u8fd0\u884c.\/position.sh 100 200&#xff0c;\u8f93\u51fa\u7ed3\u679c\u4e00\u76ee\u4e86\u7136\u3002\u8fd9\u91cc$*\u548c$&#064;\u7684\u533a\u522b&#xff0c;\u5728\u540e\u9762for\u5faa\u73af\u91cc\u4f1a\u4f53\u73b0\u5f97\u66f4\u660e\u663e\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a7278920a91c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>5. \u9884\u5b9a\u4e49\u53d8\u91cf&#xff1a;Shell\u63d0\u524d\u5b9a\u4e49\u597d\u7684<\/h3>\n<p>\u8fd9\u51e0\u4e2a\u53d8\u91cf\u4e0d\u7528\u81ea\u5df1\u5b9a\u4e49&#xff0c;\u76f4\u63a5\u5c31\u80fd\u7528&#xff0c;\u5199\u811a\u672c\u5224\u65ad\u72b6\u6001\u7684\u65f6\u5019\u8d85\u5b9e\u7528&#xff1a;<\/p>\n<ul>\n<li>$$&#xff1a;\u5f53\u524d\u811a\u672c\u8fd0\u884c\u7684\u8fdb\u7a0b\u53f7&#xff08;PID&#xff09;<\/li>\n<li>$!&#xff1a;\u540e\u53f0\u8fd0\u884c\u7684\u6700\u540e\u4e00\u4e2a\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u53f7<\/li>\n<li>$?&#xff1a;\u4e0a\u4e00\u6761\u547d\u4ee4\u7684\u6267\u884c\u72b6\u6001&#xff0c;0\u4ee3\u8868\u6267\u884c\u6210\u529f&#xff0c;\u975e0\u4ee3\u8868\u6267\u884c\u5931\u8d25<\/li>\n<\/ul>\n<p>\u5c24\u5176\u662f$?&#xff0c;\u5199\u811a\u672c\u7684\u65f6\u5019\u5224\u65ad\u4e0a\u4e00\u6b65\u6709\u6ca1\u6709\u6267\u884c\u6210\u529f&#xff0c;\u5168\u9760\u5b83\u3002<\/p>\n<h2>\u4e09\u3001Shell\u8fd0\u7b97\u7b26&#xff1a;\u7b97\u6570\u8fd0\u7b97\u600e\u4e48\u5199<\/h2>\n<p>Shell\u91cc\u7684\u7b97\u6570\u8fd0\u7b97\u4e0d\u80fd\u76f4\u63a5\u51991&#043;2&#xff0c;\u6709\u4e09\u79cd\u56fa\u5b9a\u5199\u6cd5&#xff0c;\u6211\u4e2a\u4eba\u6700\u63a8\u8350\u7b2c\u4e8c\u79cd&#xff0c;\u7701\u4e8b\u53c8\u4e0d\u5bb9\u6613\u9519\u3002<\/p>\n<li>$((\u8fd0\u7b97\u5f0f))<\/li>\n<li>$[\u8fd0\u7b97\u5f0f] \u2705 \u63a8\u8350<\/li>\n<li>expr \u8fd0\u7b97\u5f0f<\/li>\n<p>\u4e3e\u4e2a\u4f8b\u5b50&#xff0c;\u8ba1\u7b973*(5&#043;1)&#xff1a;<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token comment\"># \u5199\u6cd51<\/span><br \/>\n<span class=\"token assign-left variable\">RESULT1<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\"><span class=\"token variable\">$((<\/span><span class=\"token number\">3<\/span><span class=\"token operator\">*<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span><span class=\"token operator\">&#043;<\/span><span class=\"token number\">1<\/span><span class=\"token variable\">))<\/span><\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u7ed3\u679c1&#xff1a;<span class=\"token variable\">$RESULT1<\/span>&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u5199\u6cd52&#xff1a;\u6700\u7b80\u6d01&#xff0c;\u63a8\u8350\u7528<\/span><br \/>\n<span class=\"token assign-left variable\">RESULT2<\/span><span class=\"token operator\">&#061;<\/span>$<span class=\"token punctuation\">[<\/span><span class=\"token number\">3<\/span>*<span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span>&#043;1<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u7ed3\u679c2&#xff1a;<span class=\"token variable\">$RESULT2<\/span>&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u5199\u6cd53&#xff1a;expr&#xff0c;\u8fd0\u7b97\u7b26\u4e24\u8fb9\u5fc5\u987b\u6709\u7a7a\u683c&#xff0c;\u4e58\u53f7\u8981\u8f6c\u4e49<\/span><br \/>\n<span class=\"token assign-left variable\">TEMP<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\"><span class=\"token variable\">&#096;<\/span><span class=\"token function\">expr<\/span> <span class=\"token number\">5<\/span> &#043; <span class=\"token number\">1<\/span><span class=\"token variable\">&#096;<\/span><\/span><br \/>\n<span class=\"token assign-left variable\">RESULT3<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\"><span class=\"token variable\">&#096;<\/span><span class=\"token function\">expr<\/span> <span class=\"token number\">3<\/span> <span class=\"token punctuation\">\\\\<\/span>* $TEMP<span class=\"token variable\">&#096;<\/span><\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u7ed3\u679c3&#xff1a;<span class=\"token variable\">$RESULT3<\/span>&#034;<\/span><\/p>\n<p>\u8fd0\u884c\u5b9e\u4f8b\u5982\u4e0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a7278921bf88.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> \u8fd0\u884c\u7ed3\u679c\u4e3a&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a72789226735.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>expr\u5199\u6cd5\u7279\u522b\u9ebb\u70e6&#xff0c;\u7a7a\u683c\u3001\u8f6c\u4e49\u7b26\u5f88\u5bb9\u6613\u5199\u9519&#xff0c;\u65e5\u5e38\u5199\u811a\u672c\u57fa\u672c\u90fd\u7528$[]&#xff0c;\u7b80\u5355\u7c97\u66b4\u3002<\/p>\n<h2>\u56db\u3001\u6761\u4ef6\u5224\u65ad&#xff1a;\u903b\u8f91\u63a7\u5236\u7684\u57fa\u7840<\/h2>\n<h3>\u57fa\u672c\u8bed\u6cd5<\/h3>\n<p><span class=\"token punctuation\">[<\/span> \u6761\u4ef6\u8868\u8fbe\u5f0f <span class=\"token punctuation\">]<\/span><\/p>\n<p>\u26a0\ufe0f \u5de8\u5751\u63d0\u9192&#xff1a;\u4e2d\u62ec\u53f7\u4e24\u8fb9\u5fc5\u987b\u6709\u7a7a\u683c&#xff01;[a&#061;b]\u8fd9\u4e48\u5199\u5fc5\u9519&#xff0c;\u6b63\u786e\u5199\u6cd5\u662f[ a &#061; b ]\u3002<\/p>\n<p>\u6761\u4ef6\u4e3a\u7a7a\u7684\u65f6\u5019\u8fd4\u56defalse&#xff0c;\u6709\u5185\u5bb9\u5c31\u8fd4\u56detrue&#xff0c;\u6240\u4ee5[ abc ]\u7684\u7ed3\u679c\u662f\u771f&#xff0c;[ ]\u662f\u5047\u3002<\/p>\n<h3>\u5e38\u7528\u5224\u65ad\u6761\u4ef6<\/h3>\n<h4>&#xff08;1&#xff09;\u5b57\u7b26\u4e32\u6bd4\u8f83<\/h4>\n<ul>\n<li>&#061;&#xff1a;\u5224\u65ad\u4e24\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49<\/li>\n<li>!&#061;&#xff1a;\u5224\u65ad\u4e24\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u4e0d\u76f8\u7b49<\/li>\n<\/ul>\n<h4>&#xff08;2&#xff09;\u6574\u6570\u6bd4\u8f83<\/h4>\n<ul>\n<li>-lt&#xff1a;\u5c0f\u4e8e&#xff08;less than&#xff09;<\/li>\n<li>-gt&#xff1a;\u5927\u4e8e&#xff08;greater than&#xff09;<\/li>\n<li>-le&#xff1a;\u5c0f\u4e8e\u7b49\u4e8e<\/li>\n<li>-ge&#xff1a;\u5927\u4e8e\u7b49\u4e8e<\/li>\n<li>-eq&#xff1a;\u7b49\u4e8e<\/li>\n<li>-ne&#xff1a;\u4e0d\u7b49\u4e8e<\/li>\n<\/ul>\n<h4>&#xff08;3&#xff09;\u6587\u4ef6\u6743\u9650\u5224\u65ad<\/h4>\n<ul>\n<li>-r&#xff1a;\u6709\u8bfb\u6743\u9650<\/li>\n<li>-w&#xff1a;\u6709\u5199\u6743\u9650<\/li>\n<li>-x&#xff1a;\u6709\u6267\u884c\u6743\u9650<\/li>\n<\/ul>\n<h4>&#xff08;4&#xff09;\u6587\u4ef6\u7c7b\u578b\u5224\u65ad<\/h4>\n<ul>\n<li>-f&#xff1a;\u5b58\u5728\u4e14\u662f\u666e\u901a\u6587\u4ef6<\/li>\n<li>-e&#xff1a;\u6587\u4ef6\/\u76ee\u5f55\u5b58\u5728<\/li>\n<li>-d&#xff1a;\u5b58\u5728\u4e14\u662f\u76ee\u5f55<\/li>\n<\/ul>\n<h3>if\u5206\u652f\u8bed\u53e5<\/h3>\n<p>if\u8bed\u53e5\u7684\u7ed3\u5c3e\u662ffi&#xff0c;\u5c31\u662fif\u53cd\u8fc7\u6765\u5199&#xff0c;\u521a\u5f00\u59cb\u8bb0\u7684\u65f6\u5019\u89c9\u5f97\u7279\u522b\u6709\u610f\u601d\u3002<\/p>\n<p>if\u5206\u652f\u8bed\u53e5\u4e2d\u7ed3\u5c3efi\u5fc5\u987b\u52a0<\/p>\n<p><span class=\"token comment\"># \u5355\u5206\u652f<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">[<\/span> \u6761\u4ef6 <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">then<\/span><br \/>\n    \u6267\u884c\u4ee3\u7801<br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p><span class=\"token comment\"># \u591a\u5206\u652f<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">[<\/span> \u6761\u4ef61 <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">then<\/span><br \/>\n    \u4ee3\u78011<br \/>\n<span class=\"token keyword\">elif<\/span> <span class=\"token punctuation\">[<\/span> \u6761\u4ef62 <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">then<\/span><br \/>\n    \u4ee3\u78012<br \/>\n<span class=\"token keyword\">else<\/span><br \/>\n    \u4ee3\u78013<br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p><span class=\"token comment\"># \u5224\u65ad\u6587\u4ef6\u662f\u5426\u5b58\u5728<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token parameter variable\">-f<\/span> \u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84 <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">then<\/span><br \/>\n    \u4ee3\u7801<br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p>\u4e3e\u4e2a\u7ecf\u5178\u4f8b\u5b50&#xff1a;\u8f93\u5165\u5206\u6570&#xff0c;\u5224\u65ad\u7b49\u7ea7<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token variable\">$1<\/span> <span class=\"token parameter variable\">-ge<\/span> <span class=\"token number\">80<\/span> <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">then<\/span><br \/>\n    <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u4f18\u79c0&#034;<\/span><br \/>\n<span class=\"token keyword\">elif<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token variable\">$1<\/span> <span class=\"token parameter variable\">-ge<\/span> <span class=\"token number\">70<\/span> <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">then<\/span><br \/>\n    <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u826f\u597d&#034;<\/span><br \/>\n<span class=\"token keyword\">elif<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token variable\">$1<\/span> <span class=\"token parameter variable\">-ge<\/span> <span class=\"token number\">60<\/span> <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">then<\/span><br \/>\n    <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u53ca\u683c&#034;<\/span><br \/>\n<span class=\"token keyword\">else<\/span><br \/>\n    <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u4e0d\u53ca\u683c&#034;<\/span><br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<p>\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a72789230686.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>case\u5206\u652f\u8bed\u53e5<\/h3>\n<p>case\u7684\u7ed3\u5c3e\u662fesac&#xff0c;\u540c\u6837\u662f\u53cd\u8fc7\u6765\u8bb0\u3002\u6bcf\u4e2a\u5206\u652f\u7ed3\u5c3e\u8981\u5199\u4e24\u4e2a\u5206\u53f7;;\u3002<\/p>\n<p><span class=\"token keyword\">case<\/span> $\u53d8\u91cf\u540d <span class=\"token keyword\">in<\/span><br \/>\n<span class=\"token string\">&#034;\u503c1&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    \u4ee3\u78011<br \/>\n<span class=\"token punctuation\">;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token string\">&#034;\u503c2&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    \u4ee3\u78012<br \/>\n<span class=\"token punctuation\">;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n*<span class=\"token punctuation\">)<\/span><br \/>\n    \u9ed8\u8ba4\u6267\u884c\u7684\u4ee3\u7801<br \/>\n<span class=\"token punctuation\">;<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">esac<\/span><\/p>\n<p>\u6267\u884c\u7ed3\u679c\u5982\u4e0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a7278923a91f.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/> <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a72789244d21.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u4e94\u3001\u5faa\u73af\u8bed\u53e5&#xff1a;\u6279\u91cf\u64cd\u4f5c\u7684\u795e\u5668<\/h2>\n<h3>1. for\u5faa\u73af<\/h3>\n<p>for\u5faa\u73af\u6709\u4e24\u79cd\u5e38\u7528\u5199\u6cd5&#xff0c;\u9002\u7528\u573a\u666f\u4e0d\u4e00\u6837\u3002<\/p>\n<h4>\u5199\u6cd51&#xff1a;\u904d\u5386\u53c2\u6570\/\u5217\u8868<\/h4>\n<p><span class=\"token keyword\">for<\/span> \u53d8\u91cf <span class=\"token keyword\">in<\/span> \u503c1 \u503c2 \u503c3<br \/>\n<span class=\"token keyword\">do<\/span><br \/>\n    \u5faa\u73af\u4f53<br \/>\n<span class=\"token keyword\">done<\/span><\/p>\n<p>\u8fd9\u4e2a\u5199\u6cd5\u7279\u522b\u9002\u5408\u904d\u5386\u8f93\u5165\u53c2\u6570&#xff0c;\u8fd9\u91cc\u5c31\u80fd\u770b\u51fa$*\u548c$&#064;\u7684\u533a\u522b\u4e86&#xff1a;<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;&#8212;-\u6d4b\u8bd5\\\\<span class=\"token variable\">$*<\/span>&#8212;-&#034;<\/span><br \/>\n<span class=\"token keyword\">for<\/span> <span class=\"token for-or-select variable\">i<\/span> <span class=\"token keyword\">in<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$*<\/span>&#034;<\/span><br \/>\n<span class=\"token keyword\">do<\/span><br \/>\n    <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u53c2\u6570&#xff1a;<span class=\"token variable\">$i<\/span>&#034;<\/span><br \/>\n<span class=\"token keyword\">done<\/span><\/p>\n<p><span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;&#8212;-\u6d4b\u8bd5\\\\<span class=\"token variable\">$&#064;<\/span>&#8212;-&#034;<\/span><br \/>\n<span class=\"token keyword\">for<\/span> <span class=\"token for-or-select variable\">i<\/span> <span class=\"token keyword\">in<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">$&#064;<\/span>&#034;<\/span><br \/>\n<span class=\"token keyword\">do<\/span><br \/>\n    <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u53c2\u6570&#xff1a;<span class=\"token variable\">$i<\/span>&#034;<\/span><br \/>\n<span class=\"token keyword\">done<\/span><\/p>\n<p>\u8fd0\u884c.\/test.sh 1 2 3&#xff0c;$*\u53ea\u4f1a\u8f93\u51fa\u4e00\u884c\u201c\u53c2\u6570&#xff1a;1 2 3\u201d&#xff0c;\u800c$&#064;\u4f1a\u8f93\u51fa\u4e09\u884c&#xff0c;\u5206\u522b\u662f1\u30012\u30013\u3002 \u8fd0\u884c\u7ed3\u679c\u5982\u4e0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a7278925287f.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a7278925dacb.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h4>\u5199\u6cd52&#xff1a;\u7c7bC\u8bed\u8a00\u5faa\u73af<\/h4>\n<p><span class=\"token keyword\">for<\/span><span class=\"token variable\"><span class=\"token punctuation\">((<\/span>\u521d\u59cb\u503c<span class=\"token punctuation\">;<\/span>\u5faa\u73af\u6761\u4ef6<span class=\"token punctuation\">;<\/span>\u53d8\u91cf\u53d8\u5316<span class=\"token punctuation\">))<\/span><\/span><br \/>\n<span class=\"token keyword\">do<\/span><br \/>\n    \u5faa\u73af\u4f53<br \/>\n<span class=\"token keyword\">done<\/span><\/p>\n<p>\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a7278926a6af.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a7278927342c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u7ecf\u5178\u4f8b\u9898&#xff1a;\u6c421\u5230100\u7684\u548c<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token assign-left variable\">SUM<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><br \/>\n<span class=\"token keyword\">for<\/span><span class=\"token variable\"><span class=\"token punctuation\">((<\/span>i<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">;<\/span>i<span class=\"token operator\">&lt;&#061;<\/span><span class=\"token number\">100<\/span><span class=\"token punctuation\">;<\/span>i<span class=\"token operator\">&#043;&#043;<\/span><span class=\"token punctuation\">))<\/span><\/span><br \/>\n<span class=\"token keyword\">do<\/span><br \/>\n    <span class=\"token assign-left variable\">SUM<\/span><span class=\"token operator\">&#061;<\/span>$<span class=\"token punctuation\">[<\/span><span class=\"token variable\">$SUM<\/span>&#043;<span class=\"token variable\">$i<\/span><span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">done<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;1-100\u7684\u548c\u662f&#xff1a;<span class=\"token variable\">$SUM<\/span>&#034;<\/span><\/p>\n<p>\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234106-6a727892884d1.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>2. while\u5faa\u73af<\/h3>\n<p>while\u5faa\u73af\u548c\u5176\u4ed6\u8bed\u8a00\u903b\u8f91\u4e00\u6837&#xff0c;\u6761\u4ef6\u6ee1\u8db3\u5c31\u4e00\u76f4\u5faa\u73af\u3002<\/p>\n<p><span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">[<\/span> \u6761\u4ef6 <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">do<\/span><br \/>\n    \u5faa\u73af\u4f53<br \/>\n<span class=\"token keyword\">done<\/span><\/p>\n<p>\u540c\u6837\u7528\u6c421\u5230100\u7684\u548c\u4e3e\u4f8b&#xff1a;<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token assign-left variable\">SUM<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><br \/>\n<span class=\"token assign-left variable\">i<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><br \/>\n<span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">[<\/span> <span class=\"token variable\">$i<\/span> <span class=\"token parameter variable\">-le<\/span> <span class=\"token number\">100<\/span> <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">do<\/span><br \/>\n    <span class=\"token assign-left variable\">SUM<\/span><span class=\"token operator\">&#061;<\/span>$<span class=\"token punctuation\">[<\/span><span class=\"token variable\">$SUM<\/span>&#043;<span class=\"token variable\">$i<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    <span class=\"token assign-left variable\">i<\/span><span class=\"token operator\">&#061;<\/span>$<span class=\"token punctuation\">[<\/span><span class=\"token variable\">$i<\/span>&#043;1<span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">done<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u603b\u548c\u662f&#xff1a;<span class=\"token variable\">$SUM<\/span>&#034;<\/span><\/p>\n<h2>\u516d\u3001read\u8bfb\u53d6\u8f93\u5165&#xff1a;\u8ba9\u811a\u672c\u53ef\u4ee5\u4ea4\u4e92<\/h2>\n<p>\u5982\u679c\u60f3\u8ba9\u811a\u672c\u8fd0\u884c\u7684\u65f6\u5019&#xff0c;\u63d0\u793a\u7528\u6237\u8f93\u5165\u5185\u5bb9&#xff0c;\u5c31\u8981\u7528\u5230read\u547d\u4ee4\u3002\u4e24\u4e2a\u6700\u5e38\u7528\u7684\u53c2\u6570&#xff1a;<\/p>\n<ul>\n<li>-p&#xff1a;\u6307\u5b9a\u63d0\u793a\u6587\u5b57<\/li>\n<li>-t&#xff1a;\u6307\u5b9a\u7b49\u5f85\u8d85\u65f6\u65f6\u95f4&#xff0c;\u5355\u4f4d\u79d2&#xff0c;\u8d85\u65f6\u5c31\u4e0d\u7b49\u4e86<\/li>\n<\/ul>\n<p>\u4e3e\u4e2a\u4f8b\u5b50&#xff1a;<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token comment\"># \u63d0\u793a\u7528\u6237\u8f93\u5165&#xff0c;\u4e0d\u9650\u65f6\u95f4<\/span><br \/>\n<span class=\"token builtin class-name\">read<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token string\">&#034;\u8bf7\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570\u5b57&#xff1a;&#034;<\/span> NUM1<br \/>\n<span class=\"token comment\"># \u63d0\u793a\u7528\u6237\u8f93\u5165&#xff0c;10\u79d2\u5185\u6ca1\u8f93\u5165\u5c31\u8df3\u8fc7<\/span><br \/>\n<span class=\"token builtin class-name\">read<\/span> <span class=\"token parameter variable\">-t<\/span> <span class=\"token number\">10<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token string\">&#034;\u8bf7\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570\u5b57&#xff08;10\u79d2\u5185&#xff09;&#xff1a;&#034;<\/span> NUM2<br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u4e24\u4e2a\u6570\u7684\u548c\u662f&#xff1a;$[<span class=\"token variable\">$NUM1<\/span>&#043;<span class=\"token variable\">$NUM2<\/span>]&#034;<\/span><\/p>\n<h2>\u4e03\u3001Shell\u51fd\u6570&#xff1a;\u5c01\u88c5\u590d\u7528\u4ee3\u7801<\/h2>\n<p>Shell\u91cc\u6709\u7cfb\u7edf\u81ea\u5e26\u7684\u5de5\u5177\u51fd\u6570&#xff0c;\u4e5f\u53ef\u4ee5\u81ea\u5df1\u5b9a\u4e49\u51fd\u6570\u3002<\/p>\n<h3>1. \u4e24\u4e2a\u8d85\u5b9e\u7528\u7684\u7cfb\u7edf\u51fd\u6570<\/h3>\n<ul>\n<li>basename&#xff1a;\u4ece\u5b8c\u6574\u8def\u5f84\u91cc\u62a0\u51fa\u6587\u4ef6\u540d<span class=\"token function\">basename<\/span> \/home\/test\/a.txt  <span class=\"token comment\"># \u8f93\u51fa a.txt<\/span><br \/>\n<span class=\"token function\">basename<\/span> \/home\/test\/a.txt .txt  <span class=\"token comment\"># \u53bb\u6389\u540e\u7f00&#xff0c;\u8f93\u51fa a<\/span>\n <\/li>\n<li>dirname&#xff1a;\u4ece\u5b8c\u6574\u8def\u5f84\u91cc\u62a0\u51fa\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\u8def\u5f84<span class=\"token function\">dirname<\/span> \/home\/test\/a.txt  <span class=\"token comment\"># \u8f93\u51fa \/home\/test<\/span>\n <\/li>\n<\/ul>\n<p>\u5904\u7406\u6587\u4ef6\u8def\u5f84\u7684\u65f6\u5019&#xff0c;\u8fd9\u4e24\u4e2a\u51fd\u6570\u5de8\u597d\u7528&#xff0c;\u4e0d\u7528\u81ea\u5df1\u5199\u5b57\u7b26\u4e32\u5207\u5272\u3002<\/p>\n<h3>2. \u81ea\u5b9a\u4e49\u51fd\u6570<\/h3>\n<p>Shell\u51fd\u6570\u7684\u8bed\u6cd5\u548c\u5176\u4ed6\u8bed\u8a00\u6709\u70b9\u4e0d\u4e00\u6837&#xff1a;\u53c2\u6570\u4e0d\u7528\u5199\u5728\u62ec\u53f7\u91cc&#xff0c;\u8c03\u7528\u7684\u65f6\u5019\u76f4\u63a5\u8ddf\u5728\u51fd\u6570\u540d\u540e\u9762\u3002<\/p>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token comment\"># \u5b9a\u4e49\u51fd\u6570<\/span><br \/>\n<span class=\"token keyword\">function<\/span> <span class=\"token function-name function\">getSum<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token assign-left variable\">SUM<\/span><span class=\"token operator\">&#061;<\/span>$<span class=\"token punctuation\">[<\/span><span class=\"token variable\">$n1<\/span>&#043;<span class=\"token variable\">$n2<\/span><span class=\"token punctuation\">]<\/span><br \/>\n    <span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;\u4e24\u6570\u4e4b\u548c\u662f&#xff1a;<span class=\"token variable\">$SUM<\/span>&#034;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\"># \u8bfb\u53d6\u7528\u6237\u8f93\u5165<\/span><br \/>\n<span class=\"token builtin class-name\">read<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token string\">&#034;\u8f93\u5165\u7b2c\u4e00\u4e2a\u6570&#xff1a;&#034;<\/span> n1<br \/>\n<span class=\"token builtin class-name\">read<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token string\">&#034;\u8f93\u5165\u7b2c\u4e8c\u4e2a\u6570&#xff1a;&#034;<\/span> n2<\/p>\n<p><span class=\"token comment\"># \u8c03\u7528\u51fd\u6570&#xff0c;\u53c2\u6570\u76f4\u63a5\u5199\u5728\u540e\u9762<\/span><br \/>\ngetSum <span class=\"token variable\">$n1<\/span> <span class=\"token variable\">$n2<\/span><\/p>\n<p>\u26a0\ufe0f \u6ce8\u610f&#xff1a;\u51fd\u6570\u5fc5\u987b\u5b9a\u4e49\u5728\u8c03\u7528\u524d\u9762&#xff0c;Shell\u662f\u4ece\u4e0a\u5f80\u4e0b\u6267\u884c\u7684&#xff0c;\u5148\u5b9a\u4e49\u540e\u8c03\u7528\u3002<\/p>\n<h2>\u516b\u3001\u5b9e\u6218\u6848\u4f8b&#xff1a;MySQL\u5b9a\u65f6\u81ea\u52a8\u5907\u4efd<\/h2>\n<p>\u5b66\u4e86\u8fd9\u4e48\u591a\u8bed\u6cd5&#xff0c;\u603b\u5f97\u505a\u70b9\u5b9e\u9645\u7684\u4e1c\u897f\u3002\u8fd9\u4e2aMySQL\u5907\u4efd\u811a\u672c\u662f\u4f01\u4e1a\u91cc\u771f\u7684\u4f1a\u7528\u7684&#xff0c;\u5199\u5b8c\u7279\u522b\u6709\u6210\u5c31\u611f\u3002<\/p>\n<h3>\u9700\u6c42<\/h3>\n<li>\u6bcf\u5929\u51cc\u66682:30\u81ea\u52a8\u5907\u4efdMySQL\u6570\u636e\u5e93&#xff1b;<\/li>\n<li>\u5907\u4efd\u6587\u4ef6\u4ee5\u5907\u4efd\u65f6\u95f4\u547d\u540d&#xff0c;\u6253\u5305\u6210tar.gz\u683c\u5f0f&#xff1b;<\/li>\n<li>\u81ea\u52a8\u5220\u966410\u5929\u524d\u7684\u65e7\u5907\u4efd\u6587\u4ef6&#xff1b;<\/li>\n<li>\u5907\u4efd\u5f00\u59cb\u548c\u7ed3\u675f\u7ed9\u51fa\u63d0\u793a\u3002<\/li>\n<h3>\u811a\u672c\u5b9e\u73b0<\/h3>\n<p><span class=\"token shebang important\">#!\/bin\/bash<\/span><br \/>\n<span class=\"token comment\"># \u5907\u4efd\u6587\u4ef6\u5b58\u653e\u76ee\u5f55<\/span><br \/>\n<span class=\"token assign-left variable\">BACKUP<\/span><span class=\"token operator\">&#061;<\/span>\/data\/backup\/db<br \/>\n<span class=\"token comment\"># \u83b7\u53d6\u5f53\u524d\u65f6\u95f4&#xff0c;\u683c\u5f0f&#xff1a;\u5e74\u6708\u65e5_\u65f6\u5206\u79d2<\/span><br \/>\n<span class=\"token assign-left variable\">DATETIME<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\"><span class=\"token variable\">$(<\/span><span class=\"token function\">date<\/span> &#043;%Y-%m-%d_%H%M%S<span class=\"token variable\">)<\/span><\/span><\/p>\n<p><span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;&#061;&#061;&#061;&#061;&#061;\u5f00\u59cb\u5907\u4efd&#xff0c;\u65f6\u95f4&#xff1a;<span class=\"token variable\">$DATETIME<\/span>&#061;&#061;&#061;&#061;&#061;&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u6570\u636e\u5e93\u914d\u7f6e<\/span><br \/>\n<span class=\"token assign-left variable\">HOST<\/span><span class=\"token operator\">&#061;<\/span>localhost<br \/>\n<span class=\"token assign-left variable\">DB_USER<\/span><span class=\"token operator\">&#061;<\/span>root<br \/>\n<span class=\"token assign-left variable\">DB_PW<\/span><span class=\"token operator\">&#061;<\/span>\u4f60\u7684\u6570\u636e\u5e93\u5bc6\u7801<br \/>\n<span class=\"token assign-left variable\">DATABASE<\/span><span class=\"token operator\">&#061;<\/span>\u8981\u5907\u4efd\u7684\u5e93\u540d<\/p>\n<p><span class=\"token comment\"># \u5982\u679c\u5907\u4efd\u76ee\u5f55\u4e0d\u5b58\u5728&#xff0c;\u5c31\u81ea\u52a8\u521b\u5efa<\/span><br \/>\n<span class=\"token punctuation\">[<\/span> <span class=\"token operator\">!<\/span> <span class=\"token parameter variable\">-d<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">${BACKUP}<\/span>\/<span class=\"token variable\">${DATETIME}<\/span>&#034;<\/span> <span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">mkdir<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token string\">&#034;<span class=\"token variable\">${BACKUP}<\/span>\/<span class=\"token variable\">${DATETIME}<\/span>&#034;<\/span><\/p>\n<p><span class=\"token comment\"># \u6267\u884c\u6570\u636e\u5e93\u5907\u4efd\u5e76\u538b\u7f29<\/span><br \/>\nmysqldump -u<span class=\"token variable\">${DB_USER}<\/span> -p<span class=\"token variable\">${DB_PW}<\/span> <span class=\"token parameter variable\">&#8211;host<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token variable\">${HOST}<\/span> <span class=\"token parameter variable\">-q<\/span> <span class=\"token parameter variable\">-R<\/span> <span class=\"token parameter variable\">&#8211;databases<\/span> <span class=\"token variable\">${DATABASE}<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">gzip<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token variable\">${BACKUP}<\/span>\/<span class=\"token variable\">${DATETIME}<\/span>\/<span class=\"token variable\">${DATETIME}<\/span>.sql.gz<\/p>\n<p><span class=\"token comment\"># \u5207\u6362\u5230\u5907\u4efd\u76ee\u5f55&#xff0c;\u628a\u6574\u4e2a\u6587\u4ef6\u5939\u6253\u5305\u6210tar.gz<\/span><br \/>\n<span class=\"token builtin class-name\">cd<\/span> <span class=\"token variable\">${BACKUP}<\/span><br \/>\n<span class=\"token function\">tar<\/span> <span class=\"token parameter variable\">-zcvf<\/span> <span class=\"token variable\">$DATETIME<\/span>.tar.gz <span class=\"token variable\">${DATETIME}<\/span><br \/>\n<span class=\"token comment\"># \u5220\u6389\u539f\u6587\u4ef6\u5939&#xff0c;\u53ea\u4fdd\u7559\u538b\u7f29\u5305<\/span><br \/>\n<span class=\"token function\">rm<\/span> <span class=\"token parameter variable\">-rf<\/span> <span class=\"token variable\">${BACKUP}<\/span>\/<span class=\"token variable\">${DATETIME}<\/span><\/p>\n<p><span class=\"token comment\"># \u5220\u966410\u5929\u524d\u7684\u5907\u4efd\u6587\u4ef6<\/span><br \/>\n<span class=\"token function\">find<\/span> <span class=\"token variable\">${BACKUP}<\/span> <span class=\"token parameter variable\">-atime<\/span> &#043;10 <span class=\"token parameter variable\">-name<\/span> <span class=\"token string\">&#034;*.tar.gz&#034;<\/span> <span class=\"token parameter variable\">-exec<\/span> <span class=\"token function\">rm<\/span> <span class=\"token parameter variable\">-rf<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span> <span class=\"token punctuation\">\\\\<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#034;&#061;&#061;&#061;&#061;&#061;\u5907\u4efd\u5b8c\u6210&#xff0c;\u6587\u4ef6&#xff1a;<span class=\"token variable\">$DATETIME<\/span>.tar.gz&#061;&#061;&#061;&#061;&#061;&#034;<\/span><\/p>\n<h3>\u8bbe\u7f6e\u5b9a\u65f6\u6267\u884c<\/h3>\n<p>\u811a\u672c\u5199\u597d\u4e4b\u540e&#xff0c;\u7528crontab\u8bbe\u7f6e\u5b9a\u65f6\u4efb\u52a1\u5c31\u80fd\u5168\u81ea\u52a8\u8fd0\u884c\u4e86&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u7f16\u8f91\u5b9a\u65f6\u4efb\u52a1<\/span><br \/>\n<span class=\"token function\">crontab<\/span> <span class=\"token parameter variable\">-e<\/span><br \/>\n<span class=\"token comment\"># \u6dfb\u52a0\u4e00\u884c&#xff1a;\u6bcf\u5929\u51cc\u66682\u70b930\u5206\u6267\u884c\u811a\u672c<\/span><br \/>\n<span class=\"token number\">30<\/span> <span class=\"token number\">2<\/span> * * * \/usr\/sbin\/mysql_db_backup.sh<\/p>\n<h2>\u603b\u7ed3<\/h2>\n<p>Shell&#xff08;Bash&#xff09;\u662fLinux\u547d\u4ee4\u884c\u89e3\u91ca\u5668&#xff0c;Shell\u811a\u672c\u5c31\u662f\u628a\u591a\u6761Linux\u547d\u4ee4\u7f16\u5199\u5230.sh\u6587\u4ef6\u5b9e\u73b0\u6279\u91cf\u81ea\u52a8\u5316\u6267\u884c&#xff0c;\u662f\u8fd0\u7ef4\u81ea\u52a8\u5316\u7684\u6838\u5fc3\u5de5\u5177\u3002<\/p>\n<h3>1\u3001\u811a\u672c\u57fa\u7840<\/h3>\n<li>\u811a\u672c\u9996\u884c\u58f0\u660e&#xff1a;#!\/bin\/bash&#xff0c;\u6307\u5b9aBash\u89e3\u91ca\u5668\u3002#\u4ee3\u8868\u6ce8\u91ca\u3002<\/li>\n<li>\u4e24\u79cd\u6267\u884c\u65b9\u5f0f<\/li>\n<ul>\n<li>chmod u&#043;x xxx.sh &amp;&amp; .\/xxx.sh&#xff1a;\u6dfb\u52a0\u6267\u884c\u6743\u9650\u540e\u8fd0\u884c&#xff08;\u63a8\u8350&#xff09;<\/li>\n<li>sh xxx.sh&#xff1a;\u76f4\u63a5\u8c03\u7528\u89e3\u91ca\u5668&#xff0c;\u4e0d\u9700\u8981\u6267\u884c\u6743\u9650<\/li>\n<\/ul>\n<h3>2\u3001\u56db\u5927\u53d8\u91cf<\/h3>\n<li>\u7cfb\u7edf\u53d8\u91cf&#xff1a;$HOME\u3001$PWD\u3001$USER&#xff0c;set\u67e5\u770b\u5168\u90e8\u7cfb\u7edf\u53d8\u91cf\u3002<\/li>\n<li>\u81ea\u5b9a\u4e49\u53d8\u91cf&#xff1a;A&#061;100&#xff0c;\u7b49\u53f7\u4e24\u8fb9\u4e0d\u80fd\u6709\u7a7a\u683c&#xff1b;\u53d6\u503c$A&#xff1b;\u64a4\u9500unset A&#xff1b;\u53ea\u8bfbreadonly B&#061;2\u3002 \u547d\u4ee4\u7ed3\u679c\u8d4b\u503c&#xff1a;D&#061;$(date)&#xff08;\u63a8\u8350&#xff09;&#xff0c;\u4e0d\u63a8\u8350\u53cd\u5f15\u53f7&#096;date&#096;\u3002<\/li>\n<li>\u73af\u5883\u53d8\u91cf&#xff1a;export \u53d8\u91cf\u540d&#061;\u503c\u5bfc\u51fa\u5168\u5c40\u53d8\u91cf&#xff1b;source \u914d\u7f6e\u6587\u4ef6\u751f\u6548\u3002<\/li>\n<li>\u4f4d\u7f6e\u53c2\u6570\u53d8\u91cf<\/li>\n<li><\/li>\n<table>\n<tr>\u53d8\u91cf\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>$0<\/td>\n<td>\u811a\u672c\u6587\u4ef6\u540d<\/td>\n<\/tr>\n<tr>\n<td>$1 $2&#8230;${10}<\/td>\n<td>\u7b2c1\u30012\u300110\u4e2a\u53c2\u6570<\/td>\n<\/tr>\n<tr>\n<td>$*<\/td>\n<td>\u5168\u90e8\u53c2\u6570&#xff0c;\u4f5c\u4e3a\u4e00\u6574\u4e2a\u5b57\u7b26\u4e32<\/td>\n<\/tr>\n<tr>\n<td>$&#064;<\/td>\n<td>\u5168\u90e8\u53c2\u6570&#xff0c;\u6bcf\u4e2a\u53c2\u6570\u72ec\u7acb&#xff08;\u5faa\u73af\u5e38\u7528&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>$#<\/td>\n<td>\u4f20\u5165\u53c2\u6570\u603b\u4e2a\u6570<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<li>\u9884\u5b9a\u4e49\u53d8\u91cf<\/li>\n<ul>\n<li>$$&#xff1a;\u5f53\u524d\u811a\u672cPID<\/li>\n<li>$!&#xff1a;\u6700\u540e\u4e00\u4e2a\u540e\u53f0\u8fdb\u7a0bPID<\/li>\n<li>$?&#xff1a;\u4e0a\u4e00\u6761\u547d\u4ee4\u8fd4\u56de\u72b6\u6001&#xff0c;0\u6210\u529f&#xff0c;\u975e0\u5931\u8d25&#xff0c;\u811a\u672c\u5224\u65ad\u5fc5\u5907\u3002<\/li>\n<\/ul>\n<h3>3\u3001\u7b97\u6570\u8fd0\u7b97<\/h3>\n<p>\u4f18\u5148\u7528 $[\u8868\u8fbe\u5f0f]&#xff0c;\u7b80\u6d01\u65b9\u4fbf&#xff1b;\u4e5f\u53ef\u7528$((\u8868\u8fbe\u5f0f))&#xff1b;expr\u8fd0\u7b97\u7b26\u524d\u540e\u5fc5\u987b\u7a7a\u683c&#xff0c;\u4e58\u53f7\\\\*\u8f6c\u4e49\u3002<\/p>\n<p><span class=\"token assign-left variable\">res<\/span><span class=\"token operator\">&#061;<\/span>$<span class=\"token punctuation\">[<\/span><span class=\"token number\">3<\/span>*<span class=\"token punctuation\">(<\/span><span class=\"token number\">5<\/span>&#043;1<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">]<\/span><\/p>\n<h3>4\u3001\u6761\u4ef6\u5224\u65ad<\/h3>\n<p>\u8bed\u6cd5&#xff1a;[ \u6761\u4ef6 ]&#xff0c;\u4e2d\u62ec\u53f7\u5185\u4fa7\u5fc5\u987b\u7559\u6709\u7a7a\u683c\u3002<\/p>\n<li>\u5b57\u7b26\u4e32&#xff1a;&#061;\u76f8\u7b49\u3001!&#061;\u4e0d\u7b49<\/li>\n<li>\u6574\u6570&#xff1a;-lt\u5c0f\u4e8e\u3001-gt\u5927\u4e8e\u3001-le\u5c0f\u4e8e\u7b49\u4e8e\u3001-ge\u5927\u4e8e\u7b49\u4e8e\u3001-eq\u7b49\u4e8e\u3001-ne\u4e0d\u7b49\u4e8e<\/li>\n<li>\u6587\u4ef6&#xff1a;-f\u666e\u901a\u6587\u4ef6\u3001-d\u76ee\u5f55\u3001-e\u5b58\u5728&#xff1b;\u6743\u9650-r -w -x<\/li>\n<h4>\u5206\u652f\u8bed\u53e5<\/h4>\n<li>if\u8bed\u53e5&#xff0c;\u7ed3\u675f\u6807\u8bb0fi<\/li>\n<p><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">[<\/span> \u6761\u4ef6 <span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><span class=\"token keyword\">then<\/span><br \/>\n<span class=\"token punctuation\">..<\/span>.<br \/>\n<span class=\"token keyword\">elif<\/span> <span class=\"token punctuation\">[<\/span>\u6761\u4ef6<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><span class=\"token keyword\">then<\/span><br \/>\n<span class=\"token punctuation\">..<\/span>.<br \/>\n<span class=\"token keyword\">else<\/span><br \/>\n<span class=\"token punctuation\">..<\/span>.<br \/>\n<span class=\"token keyword\">fi<\/span><\/p>\n<li>case\u8bed\u53e5&#xff0c;\u7ed3\u675f\u6807\u8bb0esac&#xff0c;\u6bcf\u4e2a\u5206\u652f\u672b\u5c3e;;\u3002<\/li>\n<h3>5\u3001\u5faa\u73af<\/h3>\n<li>for\u5faa\u73af<\/li>\n<ul>\n<li>\u904d\u5386&#xff1a;for i in \u503c1 \u503c2 \u503c3; do &#8230; done&#xff0c;\u533a\u5206&#034;$*&#034;\u4e0e&#034;$&#064;&#034;<\/li>\n<li>C\u98ce\u683c\u8ba1\u6570&#xff1a;for((i&#061;1;i&lt;&#061;100;i&#043;&#043;));do &#8230; done<\/li>\n<\/ul>\n<li>while\u5faa\u73af&#xff1a;\u6761\u4ef6\u6210\u7acb\u5faa\u73af<\/li>\n<p><span class=\"token keyword\">while<\/span> <span class=\"token punctuation\">[<\/span> \u6761\u4ef6 <span class=\"token punctuation\">]<\/span><br \/>\n<span class=\"token keyword\">do<\/span><br \/>\n<span class=\"token keyword\">done<\/span><\/p>\n<h3>6\u3001\u4ea4\u4e92\u8f93\u5165read<\/h3>\n<ul>\n<li>-p\u63d0\u793a\u6587\u5b57&#xff0c;-t\u8d85\u65f6\u79d2\u6570<\/li>\n<\/ul>\n<p><span class=\"token builtin class-name\">read<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token string\">&#034;\u63d0\u793a\u6587\u5b57&#034;<\/span> num<br \/>\n<span class=\"token builtin class-name\">read<\/span> <span class=\"token parameter variable\">-t<\/span> <span class=\"token number\">10<\/span> <span class=\"token parameter variable\">-p<\/span> <span class=\"token string\">&#034;10\u79d2\u8d85\u65f6\u8f93\u5165&#034;<\/span> num2<\/p>\n<h3>7\u3001\u51fd\u6570<\/h3>\n<li>\u5185\u7f6e\u5de5\u5177<\/li>\n<ul>\n<li>basename \u83b7\u53d6\u6587\u4ef6\u540d<\/li>\n<li>dirname \u83b7\u53d6\u76ee\u5f55\u8def\u5f84<\/li>\n<\/ul>\n<li>\u81ea\u5b9a\u4e49\u51fd\u6570&#xff1a;\u5fc5\u987b\u5148\u5b9a\u4e49&#xff0c;\u540e\u8c03\u7528&#xff0c;\u53c2\u6570\u76f4\u63a5\u8ddf\u51fd\u6570\u540d\u540e\u9762&#xff0c;\u4e0d\u5199\u62ec\u53f7\u3002<\/li>\n<p><span class=\"token keyword\">function<\/span> <span class=\"token function-name function\">fun<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\nfun \u53c2\u65701 \u53c2\u65702<\/p>\n<h3>8\u3001\u4f01\u4e1a\u5b9e\u6218&#xff1a;MySQL\u5b9a\u65f6\u5907\u4efd<\/h3>\n<li>\u4f7f\u7528mysqldump\u505a\u6570\u636e\u5e93\u5907\u4efd&#xff0c;\u914d\u5408gzip\u538b\u7f29&#xff1b;<\/li>\n<li>find\u547d\u4ee4\u6e05\u7406N\u5929\u524d\u8fc7\u671f\u5907\u4efd&#xff1b;<\/li>\n<li>\u914d\u5408crontab -e\u914d\u7f6e\u5b9a\u65f6\u4efb\u52a1&#xff0c;\u5b9e\u73b0\u5b9a\u65f6\u81ea\u52a8\u5907\u4efd\u3002<\/li>\n<p>\u9ad8\u9891\u8e29\u5751\u6c47\u603b<\/p>\n<li>\u53d8\u91cf\u8d4b\u503c\u7b49\u53f7\u4e0d\u80fd\u52a0\u7a7a\u683c<\/li>\n<li>[ ]\u6761\u4ef6\u5224\u65ad&#xff0c;\u62ec\u53f7\u5185\u90e8\u4e24\u4fa7\u5fc5\u987b\u7a7a\u683c<\/li>\n<li>if\u7ed3\u5c3efi\u3001case\u7ed3\u5c3eesac\u4e0d\u80fd\u9057\u6f0f<\/li>\n<li>&#034;$*&#034;\u4e0e&#034;$&#064;&#034;\u53cc\u5f15\u53f7\u5305\u88f9\u4e0b\u5faa\u73af\u884c\u4e3a\u4e0d\u4e00\u6837<\/li>\n<li>\u51fd\u6570\u5fc5\u987b\u5199\u5728\u8c03\u7528\u4ee3\u7801\u4e4b\u524d<\/li>\n<li>$?\u5224\u65ad\u4e0a\u4e00\u6b65\u6267\u884c\u7ed3\u679c&#xff0c;\u81ea\u52a8\u5316\u811a\u672c\u5fc5\u5907<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u63d0\u793a&#xff1a;\u6587\u7ae0\u5199\u5b8c\u540e&#xff0c;\u76ee\u5f55\u53ef\u4ee5\u81ea\u52a8\u751f\u6210&#xff0c;\u5982\u4f55\u751f\u6210\u53ef\u53c2\u8003\u53f3\u8fb9\u7684\u5e2e\u52a9\u6587\u6863 \u6587\u7ae0\u76ee\u5f55\u524d\u8a00\u4e00\u3001\u5148\u641e\u61c2&#xff1a;Shell\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;\u7b2c\u4e00\u4e2aShell\u811a\u672c&#xff1a;Hello World\u811a\u672c\u7684\u4e24\u79cd\u6267\u884c\u65b9\u5f0f\u4e8c\u3001Shell\u53d8\u91cf&#xff1a;\u65b0\u624b\u5751\u6700\u591a\u7684\u5730\u65b91. \u7cfb\u7edf\u81ea\u5e26\u7684\u53d8\u91cf2. \u81ea\u5b9a\u4e49\u53d8\u91cf&#xff1a;\u8bb0\u4f4f\u201c\u7b49\u53f7\u4e24\u8fb9\u6ca1\u7a7a\u683c\u201d3. \u73af\u5883\u53d8\u91cf&#xff1a;\u5168\u5c40\u751f\u6548\u7684\u53d8\u91cf4. \u4f4d\u7f6e\u53c2\u6570\u53d8\u91cf&#xff1a;\u7ed9\u811a\u672c\u4f20\u53c2\u65705. \u9884<\/p>\n","protected":false},"author":2,"featured_media":90367,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10187,130,58,43,305,44],"topic":[],"class_list":["post-90380","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-codingplan","tag-chrome","tag-linux","tag-43","tag-305","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux\u8fdb\u9636\u6253\u602a\uff1aShell\u7f16\u7a0b\u4fdd\u59c6\u7ea7\u5165\u95e8\u6307\u5357 - \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\/90380.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux\u8fdb\u9636\u6253\u602a\uff1aShell\u7f16\u7a0b\u4fdd\u59c6\u7ea7\u5165\u95e8\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u63d0\u793a&#xff1a;\u6587\u7ae0\u5199\u5b8c\u540e&#xff0c;\u76ee\u5f55\u53ef\u4ee5\u81ea\u52a8\u751f\u6210&#xff0c;\u5982\u4f55\u751f\u6210\u53ef\u53c2\u8003\u53f3\u8fb9\u7684\u5e2e\u52a9\u6587\u6863 \u6587\u7ae0\u76ee\u5f55\u524d\u8a00\u4e00\u3001\u5148\u641e\u61c2&#xff1a;Shell\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;\u7b2c\u4e00\u4e2aShell\u811a\u672c&#xff1a;Hello World\u811a\u672c\u7684\u4e24\u79cd\u6267\u884c\u65b9\u5f0f\u4e8c\u3001Shell\u53d8\u91cf&#xff1a;\u65b0\u624b\u5751\u6700\u591a\u7684\u5730\u65b91. \u7cfb\u7edf\u81ea\u5e26\u7684\u53d8\u91cf2. \u81ea\u5b9a\u4e49\u53d8\u91cf&#xff1a;\u8bb0\u4f4f\u201c\u7b49\u53f7\u4e24\u8fb9\u6ca1\u7a7a\u683c\u201d3. \u73af\u5883\u53d8\u91cf&#xff1a;\u5168\u5c40\u751f\u6548\u7684\u53d8\u91cf4. \u4f4d\u7f6e\u53c2\u6570\u53d8\u91cf&#xff1a;\u7ed9\u811a\u672c\u4f20\u53c2\u65705. \u9884\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/90380.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-04T23:41:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234105-6a727891cd73a.png\" \/>\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=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90380.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/90380.html\",\"name\":\"Linux\u8fdb\u9636\u6253\u602a\uff1aShell\u7f16\u7a0b\u4fdd\u59c6\u7ea7\u5165\u95e8\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-04T23:41:07+00:00\",\"dateModified\":\"2026-08-04T23:41:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/90380.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/90380.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/90380.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\u8fdb\u9636\u6253\u602a\uff1aShell\u7f16\u7a0b\u4fdd\u59c6\u7ea7\u5165\u95e8\u6307\u5357\"}]},{\"@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":"Linux\u8fdb\u9636\u6253\u602a\uff1aShell\u7f16\u7a0b\u4fdd\u59c6\u7ea7\u5165\u95e8\u6307\u5357 - \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\/90380.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux\u8fdb\u9636\u6253\u602a\uff1aShell\u7f16\u7a0b\u4fdd\u59c6\u7ea7\u5165\u95e8\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u63d0\u793a&#xff1a;\u6587\u7ae0\u5199\u5b8c\u540e&#xff0c;\u76ee\u5f55\u53ef\u4ee5\u81ea\u52a8\u751f\u6210&#xff0c;\u5982\u4f55\u751f\u6210\u53ef\u53c2\u8003\u53f3\u8fb9\u7684\u5e2e\u52a9\u6587\u6863 \u6587\u7ae0\u76ee\u5f55\u524d\u8a00\u4e00\u3001\u5148\u641e\u61c2&#xff1a;Shell\u5230\u5e95\u662f\u4ec0\u4e48&#xff1f;\u7b2c\u4e00\u4e2aShell\u811a\u672c&#xff1a;Hello World\u811a\u672c\u7684\u4e24\u79cd\u6267\u884c\u65b9\u5f0f\u4e8c\u3001Shell\u53d8\u91cf&#xff1a;\u65b0\u624b\u5751\u6700\u591a\u7684\u5730\u65b91. \u7cfb\u7edf\u81ea\u5e26\u7684\u53d8\u91cf2. \u81ea\u5b9a\u4e49\u53d8\u91cf&#xff1a;\u8bb0\u4f4f\u201c\u7b49\u53f7\u4e24\u8fb9\u6ca1\u7a7a\u683c\u201d3. \u73af\u5883\u53d8\u91cf&#xff1a;\u5168\u5c40\u751f\u6548\u7684\u53d8\u91cf4. \u4f4d\u7f6e\u53c2\u6570\u53d8\u91cf&#xff1a;\u7ed9\u811a\u672c\u4f20\u53c2\u65705. \u9884","og_url":"https:\/\/www.wsisp.com\/helps\/90380.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-04T23:41:07+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260804234105-6a727891cd73a.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/90380.html","url":"https:\/\/www.wsisp.com\/helps\/90380.html","name":"Linux\u8fdb\u9636\u6253\u602a\uff1aShell\u7f16\u7a0b\u4fdd\u59c6\u7ea7\u5165\u95e8\u6307\u5357 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-04T23:41:07+00:00","dateModified":"2026-08-04T23:41:07+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/90380.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/90380.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/90380.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux\u8fdb\u9636\u6253\u602a\uff1aShell\u7f16\u7a0b\u4fdd\u59c6\u7ea7\u5165\u95e8\u6307\u5357"}]},{"@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\/90380","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=90380"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/90380\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/90367"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=90380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=90380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=90380"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=90380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}