{"id":16721,"date":"2024-11-27T09:26:49","date_gmt":"2024-11-27T01:26:49","guid":{"rendered":"https:\/\/92it.top\/?p=16721"},"modified":"2024-11-27T09:26:49","modified_gmt":"2024-11-27T01:26:49","slug":"linux-shell%e5%92%8cshell%e8%84%9a%e6%9c%ac%e8%af%a6%e8%a7%a3%ef%bc%81","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=16721","title":{"rendered":"Linux Shell\u548cShell\u811a\u672c\u8be6\u89e3\uff01"},"content":{"rendered":"\n<p>\u8f6c\u8f7d\uff1a<a href=\"https:\/\/mp.weixin.qq.com\/s?__biz=MzIwNDAyOTI2Nw==&amp;mid=2247500732&amp;idx=1&amp;sn=9501ec5dc441518e782925913ececc9a&amp;chksm=96c4ef80a1b36696fa2e25914e6e1169ed4a564a266284bc51c027ba77181e280c03385de4cd&amp;cur_album_id=2818595943724974083&amp;scene=190#rd\">Linux Shell\u548cShell\u811a\u672c\u8be6\u89e3\uff01<\/a><\/p>\n\n\n\n<p>Linux Shell \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884c\u4ea4\u4e92\u548c\u81ea\u52a8\u5316\u4efb\u52a1\u3002Shell \u811a\u672c\u662f\u4e00\u4e2a\u6216\u591a\u4e2a\u547d\u4ee4\u7684\u5e8f\u5217\uff0c\u53ef\u4ee5\u5728 Shell \u4e2d\u6267\u884c\uff0c\u7528\u4e8e\u81ea\u52a8\u5316\u4efb\u52a1\u3001\u7ba1\u7406\u7cfb\u7edf\u3001\u5904\u7406\u6587\u4ef6\u7b49\u3002\u672c\u6587\u6211\u4eec\u5c06\u8be6\u7ec6\u5206\u6790 Linux Shell \u548c Shell \u811a\u672c\u3002<\/p>\n\n\n\n<p><strong>1. \u4ec0\u4e48\u662f Linux Shell\uff1f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Linux Shell \u662f\u4e00\u4e2a\u547d\u4ee4\u884c\u89e3\u91ca\u5668\uff0c\u5b83\u63d0\u4f9b\u4e86\u7528\u6237\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u4e4b\u95f4\u7684\u63a5\u53e3\u3002\u7528\u6237\u901a\u8fc7 Shell \u53ef\u4ee5\u6267\u884c\u547d\u4ee4\u3001\u542f\u52a8\u7a0b\u5e8f\u3001\u7ba1\u7406\u6587\u4ef6\u7cfb\u7edf\u548c\u8fdb\u7a0b\u7b49\u3002\u5e38\u89c1\u7684 Shell \u6709 Bash\uff08Bourne Again Shell\uff09\u3001Zsh\u3001Ksh\u3001Csh \u7b49\u3002<\/p>\n\n\n\n<p><strong>1.1 Shell \u7684\u57fa\u672c\u529f\u80fd<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u547d\u4ee4\u89e3\u91ca<\/strong>\uff1aShell \u80fd\u591f\u89e3\u91ca\u548c\u6267\u884c\u7528\u6237\u8f93\u5165\u7684\u547d\u4ee4\u3002<\/li>\n\n\n\n<li><strong>\u811a\u672c\u7f16\u5199<\/strong>\uff1a\u7528\u6237\u53ef\u4ee5\u7f16\u5199 Shell \u811a\u672c\u81ea\u52a8\u5316\u91cd\u590d\u4efb\u52a1\u3002<\/li>\n\n\n\n<li><strong>\u53d8\u91cf\u548c\u73af\u5883\u7ba1\u7406<\/strong>\uff1aShell \u652f\u6301\u53d8\u91cf\u5b9a\u4e49\u548c\u73af\u5883\u53d8\u91cf\u7ba1\u7406\u3002<\/li>\n\n\n\n<li><strong>\u6d41\u7a0b\u63a7\u5236<\/strong>\uff1a\u5305\u62ec\u6761\u4ef6\u5224\u65ad\u3001\u5faa\u73af\u63a7\u5236\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u8fdb\u7a0b\u7ba1\u7406<\/strong>\uff1a\u542f\u52a8\u3001\u7ec8\u6b62\u548c\u7ba1\u7406\u7cfb\u7edf\u8fdb\u7a0b\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>2. Shell \u811a\u672c\u57fa\u7840<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Shell \u811a\u672c\u662f\u4e00\u79cd\u4f7f\u7528 Shell \u547d\u4ee4\u7f16\u5199\u7684\u7a0b\u5e8f\uff0c\u5176\u6269\u5c55\u540d\u901a\u5e38\u4e3a <code>.sh<\/code>\u3002\u7f16\u5199 Shell \u811a\u672c\u7684\u4e3b\u8981\u76ee\u7684\u662f\u81ea\u52a8\u5316\u91cd\u590d\u6027\u4efb\u52a1\uff0c\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n\n\n\n<p><strong>2.1 \u811a\u672c\u7684\u57fa\u672c\u7ed3\u6784<\/strong><\/p>\n\n\n\n<p>Shell \u811a\u672c\u5c55\u793a<code>Hello, World<\/code> \u7684\u4f8b\u5b50\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\necho \"Hello, World!\"<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"475\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-178-1024x475.png\" alt=\"\" class=\"wp-image-16723\" style=\"width:346px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-178-1024x475.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-178-300x139.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-178-768x357.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-178-830x385.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-178-230x107.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-178-350x162.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-178-480x223.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-178.png 1090w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<ul>\n<li><code>#!\/bin\/bash<\/code>\uff1a\u8fd9\u662f\u4e00\u4e2a Shebang\uff08\u4e5f\u79f0\u4e3a hashbang \u6216 pound-bang\uff09\uff0c\u7528\u4e8e\u6307\u5b9a\u811a\u672c\u6587\u4ef6\u5e94\u7531\u54ea\u4e2a\u89e3\u91ca\u5668\u6765\u6267\u884c\u3002\u5728 Linux \u548c\u7c7b Unix \u7cfb\u7edf\u4e2d\uff0c\u6587\u4ef6\u7684\u7b2c\u4e00\u884c\u5982\u679c\u4ee5 #! \u5f00\u5934\uff0c\u540e\u9762\u8ddf\u968f\u7684\u662f\u89e3\u91ca\u5668\u7684\u8def\u5f84\uff0c\u90a3\u4e48\u64cd\u4f5c\u7cfb\u7edf\u4f1a\u4f7f\u7528\u8be5\u89e3\u91ca\u5668\u6765\u8fd0\u884c\u8fd9\u4e2a\u811a\u672c\u3002<\/li>\n\n\n\n<li><code>echo \"Hello, World!\"<\/code>\uff1a\u8f93\u51fa\u6587\u672c\u5230\u7ec8\u7aef\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>2.2 \u53d8\u91cf<\/strong><\/p>\n\n\n\n<p>\u53d8\u91cf\u5728 Shell \u811a\u672c\u4e2d\u7528\u4e8e\u5b58\u50a8\u548c\u64cd\u4f5c\u6570\u636e\uff0c\u53d8\u91cf\u540d\u901a\u5e38\u4f7f\u7528\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf\u6784\u6210\u3002\u5982\u4e0b\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\nname=\"\u733fjava\"\necho \"Hello, $name\"<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"926\" height=\"468\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-180.png\" alt=\"\" class=\"wp-image-16725\" style=\"width:404px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-180.png 926w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-180-300x152.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-180-768x388.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-180-830x419.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-180-230x116.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-180-350x177.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-180-480x243.png 480w\" sizes=\"(max-width: 926px) 100vw, 926px\" \/><\/figure><\/div>\n\n\n<p><strong>2.3 \u6761\u4ef6\u5224\u65ad<\/strong><\/p>\n\n\n\n<p>\u6761\u4ef6\u5224\u65ad\u4f7f\u7528 <code>if<\/code> \u8bed\u53e5\u5b9e\u73b0\uff0c\u5e38\u7528\u4e8e\u6267\u884c\u4e0d\u540c\u7684\u903b\u8f91\u64cd\u4f5c\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\nnumber=10\nif [ $number -gt 5 ]; then\n  echo \"Number > 5\"\nelse\n  echo \"Number &lt;= 5\"\nfi<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"846\" height=\"554\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-181.png\" alt=\"\" class=\"wp-image-16726\" style=\"width:410px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-181.png 846w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-181-300x196.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-181-768x503.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-181-830x544.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-181-230x151.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-181-350x229.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-181-480x314.png 480w\" sizes=\"(max-width: 846px) 100vw, 846px\" \/><\/figure><\/div>\n\n\n<p><strong>2.4 \u5faa\u73af<\/strong><\/p>\n\n\n\n<p>Shell \u811a\u672c\u652f\u6301 <code>for<\/code>\u3001<code>while<\/code> \u548c <code>until<\/code> \u5faa\u73af\uff0c\u7528\u4e8e\u91cd\u590d\u6267\u884c\u547d\u4ee4\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\nfor i in 1 2 3 4 5\ndo\n  echo \"Number: $i\"\ndone<\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"740\" src=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-183-1024x740.png\" alt=\"\" class=\"wp-image-16728\" style=\"width:454px;height:auto\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-183-1024x740.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-183-300x217.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-183-768x555.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-183-830x600.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-183-230x166.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-183-350x253.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-183-480x347.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2024\/11\/image-183.png 1104w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p><strong>3. \u5e38\u7528 Shell \u547d\u4ee4<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Shell \u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u547d\u4ee4\u7528\u4e8e\u6587\u4ef6\u7ba1\u7406\u3001\u6587\u672c\u5904\u7406\u3001\u7cfb\u7edf\u76d1\u63a7\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u547d\u4ee4\uff1a<\/p>\n\n\n\n<p><strong>3.1 \u6587\u4ef6\u548c\u76ee\u5f55\u7ba1\u7406<\/strong><\/p>\n\n\n\n<ul>\n<li><code>ls<\/code>\uff1a\u5217\u51fa\u76ee\u5f55\u5185\u5bb9\u3002<\/li>\n\n\n\n<li><code>cd<\/code>\uff1a\u66f4\u6539\u5f53\u524d\u76ee\u5f55\u3002<\/li>\n\n\n\n<li><code>mkdir<\/code>\uff1a\u521b\u5efa\u65b0\u76ee\u5f55\u3002<\/li>\n\n\n\n<li><code>rm<\/code>\uff1a\u5220\u9664\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/li>\n\n\n\n<li><code>cp<\/code>\uff1a\u590d\u5236\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/li>\n\n\n\n<li><code>mv<\/code>\uff1a\u79fb\u52a8\u6216\u91cd\u547d\u540d\u6587\u4ef6\u6216\u76ee\u5f55\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>3.2 \u6587\u672c\u5904\u7406<\/strong><\/p>\n\n\n\n<ul>\n<li><code>cat<\/code>\uff1a\u663e\u793a\u6587\u4ef6\u5185\u5bb9\u3002<\/li>\n\n\n\n<li><code>grep<\/code>\uff1a\u641c\u7d22\u6587\u672c\u3002<\/li>\n\n\n\n<li><code>sed<\/code>\uff1a\u6d41\u7f16\u8f91\u5668\uff0c\u7528\u4e8e\u6587\u672c\u66ff\u6362\u548c\u683c\u5f0f\u5316\u3002<\/li>\n\n\n\n<li><code>awk<\/code>\uff1a\u5f3a\u5927\u7684\u6587\u672c\u5904\u7406\u5de5\u5177\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>3.3 \u7cfb\u7edf\u76d1\u63a7<\/strong><\/p>\n\n\n\n<ul>\n<li><code>top<\/code>\uff1a\u5b9e\u65f6\u663e\u793a\u7cfb\u7edf\u6027\u80fd\u3002<\/li>\n\n\n\n<li><code>ps<\/code>\uff1a\u663e\u793a\u5f53\u524d\u8fdb\u7a0b\u3002<\/li>\n\n\n\n<li><code>df<\/code>\uff1a\u62a5\u544a\u6587\u4ef6\u7cfb\u7edf\u78c1\u76d8\u7a7a\u95f4\u4f7f\u7528\u60c5\u51b5\u3002<\/li>\n\n\n\n<li><code>du<\/code>\uff1a\u4f30\u7b97\u6587\u4ef6\u548c\u76ee\u5f55\u7684\u78c1\u76d8\u4f7f\u7528\u60c5\u51b5\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>4. Shell \u811a\u672c\u793a\u4f8b\u5206\u6790<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>4.1 \u81ea\u52a8\u5907\u4efd\u811a\u672c<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\n# \u81ea\u52a8\u5907\u4efd\u6307\u5b9a\u76ee\u5f55\n\nSOURCE_DIR=\"\/home\/user\/documents\"\nBACKUP_DIR=\"\/home\/user\/backup\"\nDATE=$(date +%Y%m%d)\n\n# \u521b\u5efa\u5907\u4efd\u76ee\u5f55\nmkdir -p $BACKUP_DIR\/$DATE\n\n# \u590d\u5236\u6587\u4ef6\ncp -r $SOURCE_DIR\/* $BACKUP_DIR\/$DATE\n\necho \"Backup completed for $DATE\"<\/pre>\n\n\n\n<p>\u8be5\u811a\u672c\u5b9e\u73b0\u4e86\u5c06\u6307\u5b9a\u76ee\u5f55\u7684\u5185\u5bb9\u5907\u4efd\u5230\u76ee\u6807\u76ee\u5f55\uff0c\u5e76\u6309\u7167\u65e5\u671f\u7ec4\u7ec7\u5907\u4efd\u6587\u4ef6\u3002<\/p>\n\n\n\n<p><strong>4.2 \u65e5\u5fd7\u5206\u6790\u811a\u672c<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#!\/bin\/bash\n\n# \u5206\u6790\u65e5\u5fd7\u6587\u4ef6\u4e2d\u7684\u9519\u8bef\u4fe1\u606f\n\nLOG_FILE=\"\/var\/log\/syslog\"\nERROR_COUNT=$(grep -i \"error\" $LOG_FILE | wc -l)\n\necho \"Total number of errors: $ERROR_COUNT\"<\/pre>\n\n\n\n<p>\u8be5\u811a\u672c\u7528\u4e8e\u5206\u6790\u7cfb\u7edf\u65e5\u5fd7\u6587\u4ef6\u4e2d\u7684\u9519\u8bef\u4fe1\u606f\uff0c\u7edf\u8ba1\u51fa\u73b0\u7684\u9519\u8bef\u6b21\u6570\u3002<\/p>\n\n\n\n<p><strong>5. Shell \u811a\u672c\u5b9e\u9645\u5e94\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Shell \u811a\u672c\u5728\u5b9e\u9645\u5de5\u4f5c\u4e2d\u6709\u5e7f\u6cdb\u7684\u7528\u9014\uff0c\u5c24\u5176\u662f\u5728\u7cfb\u7edf\u7ba1\u7406\u3001\u81ea\u52a8\u5316\u4efb\u52a1\u548c\u5f00\u53d1\u73af\u5883\u4e2d\u3002\u4e0b\u9762\u5217\u4e3e\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\uff1a<\/p>\n\n\n\n<ol>\n<li><strong>\u81ea\u52a8\u5316\u4efb\u52a1<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u5b9a\u65f6\u4efb\u52a1\uff1a\u901a\u8fc7 <code>cron<\/code> \u5b9a\u65f6\u6267\u884c\u811a\u672c\uff0c\u81ea\u52a8\u5316\u5907\u4efd\u3001\u65e5\u5fd7\u6e05\u7406\u3001\u7cfb\u7edf\u76d1\u63a7\u7b49\u4efb\u52a1\u3002<\/li>\n\n\n\n<li>\u6279\u91cf\u5904\u7406\uff1a\u6279\u91cf\u91cd\u547d\u540d\u6587\u4ef6\u3001\u8f6c\u6362\u6587\u4ef6\u683c\u5f0f\u3001\u5904\u7406\u6570\u636e\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"2\">\n<li><strong>\u7cfb\u7edf\u7ba1\u7406<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u7528\u6237\u7ba1\u7406\uff1a\u81ea\u52a8\u521b\u5efa\u3001\u5220\u9664\u7528\u6237\u8d26\u6237\uff0c\u7ba1\u7406\u7528\u6237\u6743\u9650\u3002<\/li>\n\n\n\n<li>\u8f6f\u4ef6\u5b89\u88c5\u548c\u914d\u7f6e\uff1a\u81ea\u52a8\u5316\u5b89\u88c5\u548c\u914d\u7f6e\u8f6f\u4ef6\u5305\uff0c\u7b80\u5316\u90e8\u7f72\u8fc7\u7a0b\u3002<\/li>\n\n\n\n<li>\u7cfb\u7edf\u76d1\u63a7\uff1a\u76d1\u63a7\u7cfb\u7edf\u8d44\u6e90\u4f7f\u7528\u60c5\u51b5\uff0c\u5982CPU\u3001\u5185\u5b58\u3001\u78c1\u76d8\u7a7a\u95f4\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"3\">\n<li><strong>\u5f00\u53d1\u548c\u90e8\u7f72<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u6784\u5efa\u548c\u53d1\u5e03\uff1a\u81ea\u52a8\u5316\u7f16\u8bd1\u4ee3\u7801\u3001\u8fd0\u884c\u6d4b\u8bd5\u3001\u6253\u5305\u548c\u90e8\u7f72\u5e94\u7528\u3002<\/li>\n\n\n\n<li>\u73af\u5883\u8bbe\u7f6e\uff1a\u914d\u7f6e\u5f00\u53d1\u73af\u5883\uff0c\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u5b89\u88c5\u4f9d\u8d56\u5305\u7b49\u3002<\/li>\n\n\n\n<li>\u6301\u7eed\u96c6\u6210\/\u6301\u7eed\u90e8\u7f72\uff08CI\/CD\uff09\uff1a\u4e0e\u5de5\u5177\uff08\u5982 Jenkins\u3001GitLab CI\uff09\u96c6\u6210\uff0c\u81ea\u52a8\u5316\u6784\u5efa\u548c\u90e8\u7f72\u6d41\u7a0b\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"4\">\n<li><strong>\u6570\u636e\u5904\u7406\u548c\u5206\u6790<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u6587\u672c\u5904\u7406\uff1a\u4f7f\u7528\u5de5\u5177\uff08\u5982 <code>awk<\/code>\u3001<code>sed<\/code>\u3001<code>grep<\/code>\uff09\u8fdb\u884c\u6587\u672c\u8fc7\u6ee4\u548c\u683c\u5f0f\u5316\u3002<\/li>\n\n\n\n<li>\u6570\u636e\u8f6c\u6362\uff1a\u5904\u7406\u548c\u8f6c\u6362\u6570\u636e\u683c\u5f0f\uff0c\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u8f93\u5165\u8f93\u51fa\u9700\u6c42\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"5\">\n<li><strong>\u7f51\u7edc\u548c\u5b89\u5168<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u7f51\u7edc\u8bca\u65ad\uff1a\u81ea\u52a8\u5316\u7f51\u7edc\u914d\u7f6e\u3001\u6d4b\u8bd5\u7f51\u7edc\u8fde\u63a5\u3001\u76d1\u63a7\u7f51\u7edc\u6d41\u91cf\u3002<\/li>\n\n\n\n<li>\u5b89\u5168\u626b\u63cf\uff1a\u81ea\u52a8\u5316\u6267\u884c\u5b89\u5168\u626b\u63cf\u3001\u68c0\u67e5\u65e5\u5fd7\u6587\u4ef6\u4e2d\u7684\u5f02\u5e38\u6d3b\u52a8\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"6\">\n<li><strong>\u5907\u4efd\u548c\u6062\u590d<\/strong>\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u6570\u636e\u5907\u4efd\uff1a\u5b9a\u671f\u5907\u4efd\u6587\u4ef6\u548c\u6570\u636e\u5e93\uff0c\u786e\u4fdd\u6570\u636e\u5b89\u5168\u3002<\/li>\n\n\n\n<li>\u6062\u590d\u811a\u672c\uff1a\u81ea\u52a8\u5316\u6062\u590d\u8fc7\u7a0b\uff0c\u51cf\u5c11\u4eba\u4e3a\u9519\u8bef\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>6. Shell \u7c7b\u578b<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u6709\u591a\u79cd\u7c7b\u578b\u7684 Shell \u53ef\u4f9b\u4f7f\u7528\uff0c\u6bcf\u79cd Shell \u90fd\u6709\u5176\u72ec\u7279\u7684\u7279\u6027\u548c\u7528\u6cd5\u3002\u4e0b\u9762\u5217\u4e3e\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684 Shell \u7c7b\u578b\uff1a<\/p>\n\n\n\n<ol>\n<li>**Bourne Shell (sh)**\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u8fd9\u662f Unix \u7cfb\u7edf\u4e0a\u6700\u521d\u7684 Shell\uff0c\u7531 Stephen Bourne \u5f00\u53d1\u3002<\/li>\n\n\n\n<li>\u7b80\u5355\u4e14\u9ad8\u6548\uff0c\u9002\u5408\u7f16\u5199\u811a\u672c\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"2\">\n<li>**Bourne Again Shell (bash)**\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>GNU \u9879\u76ee\u7684\u6269\u5c55\u7248 Bourne Shell\uff0c\u662f\u76ee\u524d\u6700\u6d41\u884c\u7684 Shell\uff0c\u5c24\u5176\u5728 Linux \u4e0a\u3002<\/li>\n\n\n\n<li>\u63d0\u4f9b\u4e86\u547d\u4ee4\u884c\u7f16\u8f91\u3001\u547d\u4ee4\u5386\u53f2\u8bb0\u5f55\u7b49\u589e\u5f3a\u529f\u80fd\u3002<\/li>\n\n\n\n<li>\u517c\u5bb9 Bourne Shell \u7684\u8bed\u6cd5\uff0c\u5e76\u589e\u52a0\u4e86\u8bb8\u591a\u65b0\u7279\u6027\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"3\">\n<li>**C Shell (csh)**\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u7c7b\u4f3c C \u8bed\u8a00\u7684\u8bed\u6cd5\u7ed3\u6784\uff0c\u9002\u5408\u4e60\u60ef C \u8bed\u8a00\u7684\u7528\u6237\u3002<\/li>\n\n\n\n<li>\u63d0\u4f9b\u4e86\u547d\u4ee4\u522b\u540d\u548c\u5386\u53f2\u8bb0\u5f55\u529f\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"4\">\n<li>**TENEX C Shell (tcsh)**\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>C Shell \u7684\u589e\u5f3a\u7248\u672c\uff0c\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u7528\u6237\u754c\u9762\u548c\u66f4\u591a\u529f\u80fd\u3002<\/li>\n\n\n\n<li>\u589e\u5f3a\u7684\u547d\u4ee4\u884c\u7f16\u8f91\u548c\u81ea\u52a8\u8865\u5168\u529f\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"5\">\n<li>**Korn Shell (ksh)**\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u7531 David Korn \u5f00\u53d1\uff0c\u517c\u5bb9 Bourne Shell\uff0c\u5e76\u63d0\u4f9b\u4e86 C Shell \u7684\u4e00\u4e9b\u7279\u6027\u3002<\/li>\n\n\n\n<li>\u63d0\u4f9b\u4e86\u9ad8\u7ea7\u7f16\u7a0b\u529f\u80fd\uff0c\u5982\u6570\u7ec4\u548c\u6d6e\u70b9\u8fd0\u7b97\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"6\">\n<li>**Z Shell (zsh)**\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u7ed3\u5408\u4e86 bash\u3001ksh \u548c tcsh \u7684\u529f\u80fd\uff0c\u662f\u4e00\u79cd\u529f\u80fd\u4e30\u5bcc\u7684 Shell\u3002<\/li>\n\n\n\n<li>\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u81ea\u52a8\u8865\u5168\u3001\u62fc\u5199\u7ea0\u6b63\u3001\u4e3b\u9898\u652f\u6301\u7b49\u529f\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<ol start=\"7\">\n<li>**Dash (Debian Almquist Shell)**\uff1a<\/li>\n<\/ol>\n\n\n\n<ul>\n<li>\u8f7b\u91cf\u7ea7\u7684 POSIX \u517c\u5bb9 Shell\uff0c\u901a\u5e38\u7528\u4e8e\u7cfb\u7edf\u542f\u52a8\u811a\u672c\u3002<\/li>\n\n\n\n<li>\u901f\u5ea6\u5feb\uff0c\u5360\u7528\u8d44\u6e90\u5c11\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6bcf\u79cd Shell \u90fd\u6709\u5176\u7279\u5b9a\u7684\u7528\u9014\u548c\u4f18\u52bf\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684 Shell \u6765\u4f7f\u7528\u3002Bash \u662f\u9ed8\u8ba4\u7684 Shell \u5728\u5927\u591a\u6570 Linux \u53d1\u884c\u7248\u4e2d\uff0c\u4f46\u5176\u4ed6 Shell \u4e5f\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u548c\u914d\u7f6e\u6765\u4f7f\u7528\u3002<\/p>\n\n\n\n<p><strong>7. \u7ed3\u8bba<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u672c\u6587\uff0c\u6211\u4eec\u5206\u6790\u4e86 Linux Shell \u548c Shell \u811a\u672c\uff0c\u5b83\u4eec\u662f\u7cfb\u7edf\u7ba1\u7406\u548c\u81ea\u52a8\u5316\u4efb\u52a1\u7684\u5f3a\u5927\u5de5\u5177\u3002\u901a\u8fc7\u638c\u63e1 Shell \u7684\u57fa\u672c\u529f\u80fd\u548c\u811a\u672c\u7f16\u5199\u6280\u5de7\uff0c\u7528\u6237\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\uff0c\u5b9e\u73b0\u590d\u6742\u4efb\u52a1\u7684\u81ea\u52a8\u5316\u5904\u7406\u3002\u5e0c\u671b\u672c\u6587\u7684\u793a\u4f8b\u548c\u5206\u6790\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u5e94\u7528 Linux Shell \u548c Shell \u811a\u672c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\uff1aLinux Shell\u548cShell\u811a\u672c\u8be6\u89e3\uff01 Linux Shell \u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u7528\u4e8e\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u8fdb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/16721"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16721"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/16721\/revisions"}],"predecessor-version":[{"id":16729,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/16721\/revisions\/16729"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16721"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}