{"id":1369,"date":"2020-05-08T22:36:34","date_gmt":"2020-05-08T14:36:34","guid":{"rendered":"http:\/\/blog.ywdevops.cn\/?p=1369"},"modified":"2022-10-27T17:26:19","modified_gmt":"2022-10-27T09:26:19","slug":"shell","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2020\/05\/08\/shell\/","title":{"rendered":"shell\u8868\u8fbe\u5f0f\u4ee5\u53ca\u8fd0\u7b97\u7b26"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u547d\u4ee4\u6267\u884c\u5b8c\u6210\u540e\u4f1a\u8fd4\u56de\u4e00\u4e2a\u9000\u51fa\u72b6\u6001\uff0c\u5982\u679c\u4e3a0\u8868\u793a\u9000\u51fa\u6210\u529f\uff0c\u5982\u4f55\u4e0d\u4e3a0\uff0c\u8868\u793a\u672a\u6210\u529f\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>\u9000\u51fa\u72b6\u6001\u53ca\u5176\u542b\u4e49\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u9000\u51fa\u72b6\u6001<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u542b\u4e49<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">0<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u8868\u793a\u547d\u4ee4\u6267\u884c\u6210\u529f\uff0c\u6ca1\u6709\u95ee\u9898<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">1~125<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6267\u884c\u5931\u8d25\uff0c\u811a\u672c\u547d\u4ee4\u3001\u7cfb\u7edf\u547d\u4ee4\u6216\u53c2\u6570\u4f20\u9012\u9519\u8bef<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">126<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5b58\u5728\u8be5\u547d\u4ee4\uff0c\u4f46\u662f\u65e0\u6cd5\u6267\u884c<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">127<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u672a\u627e\u5230\u8be5\u547d\u4ee4<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">&gt;128<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u547d\u4ee4\u88ab\u7cfb\u7edf\u5f3a\u5236\u7ed3\u675f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f8b\u5982\uff1a\u5206\u522b\u4f7f\u7528cat\u547d\u4ee4\u4ee5\u53cacdt(\u4e0d\u5b58\u5728),\u4f5c\u4e3a\u6d4b\u8bd5\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"589\" height=\"253\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/14-8.png\" alt=\"\" class=\"wp-image-1370\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/14-8.png 589w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/14-8-300x129.png 300w\" sizes=\"auto, (max-width: 589px) 100vw, 589px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\"><strong>\u6d4b\u8bd5\u547d\u4ee4\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6d4b\u8bd5\u547d\u4ee4\u7528\u4e8e\u6d4b\u8bd5\u8868\u8fbe\u5f0f\u771f\u5047\uff0c\u5982\u679c\u4e3a\u771f\uff0c\u5219\u8fd4\u56de0\uff0c\u5982\u679c\u4e3a\u5047\uff0c\u5219\u8fd4\u56de\u975e0\u6570\u503c\uff0c\u6d4b\u8bd5\u547d\u4ee4\u6709\u4e24\u79cd\u683c\u5f0f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>test   expression<\/strong><\/li><li><strong>[ expression ]<\/strong><\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u9762\u4e24\u79cd\u683c\u5f0f\u7684\u4f7f\u7528\u6548\u679c\u76f8\u540c\uff0c\u4f46\u662f<strong>\u4e00\u822c\u4f7f\u7528\u7b2c\u4e8c\u79cd\u65b9\u5f0f<\/strong>\uff0c\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u4e00\u822c\u914d\u7f6eif\u3001case\u3001while\u7b49\u8bed\u53e5\u4e00\u8d77\u4f7f\u7528\uff0cshell\u811a\u672c\u4e2d\u7684if [ ]\u4e2dif\u540e\u9762\u7684\u5373\u4e3a\u6d4b\u8bd5\u547d\u4ee4<\/p>\n\n\n\n<p class=\"has-pale-cyan-blue-background-color has-background wp-block-paragraph\">\u6ce8\u610f\uff1a[ expressiom ]\u4e2d\u7684expression\u548c\u4e2d\u62ec\u53f7\u4e4b\u95f4\u524d\u540e\u5b58\u5728\u7a7a\u683c<\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>\u6574\u6570\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6574\u6570\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7528\u4e8e\u6574\u6570\u6bd4\u8f83\uff0c\u4e0d\u80fd\u7528\u4e8e\u6bd4\u8f83\u5b57\u7b26\u4e32\u4ee5\u53ca\u6587\u4ef6\uff0c\u5982\u679c\u6bd4\u8f83\u7ed3\u679c\u6ee1\u8db3\u63d0\u4ea4\uff0c\u5219\u7ed3\u679c\u4e3a\u771f\uff08\u6d4b\u8bd5\u6761\u4ef6\u75280\u8868\u793a\uff09\uff0c\u5982\u679c\u4e0d\u6ee1\u8db3\u5219\u4e3a\u5047\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>\u6574\u6570\u6bd4\u8f83\u8fd0\u7b97\u7b26<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u8fd0\u7b97\u7b26<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u542b\u4e49<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">a -eq  b<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5982\u679ca\u7b49\u4e8eb\uff0c\u6d4b\u8bd5\u7ed3\u679c\u4e3a0<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">a -ge b<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5982\u679ca\u5927\u4e8e\u7b49\u4e8eb\uff0c\u6d4b\u8bd5\u7ed3\u679c\u4e3a0<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">a  -gt b<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5982\u679ca\u5927\u4e8eb\uff0c\u6d4b\u8bd5\u7ed3\u679c\u4e3a0<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">a  -le b<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5982\u679ca\u5c0f\u4e8e\u7b49\u4e8eb\uff0c\u6d4b\u8bd5\u7ed3\u679c\u4e3a0<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">a -lt b<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5982\u679ca\u5c0f\u4e8eb\uff0c\u6d4b\u8bd5\u7ed3\u679c\u4e3a0<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">a -ne b<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5982\u679ca\u4e0d\u7b49\u4e8eb\uff0c\u6d4b\u8bd5\u7ed3\u679c\u4e3a0<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f8b\u5982\uff1a\u6bd4\u8f83\u4e24\u4e2a\u6570\u503c\u7684\u5927\u5c0f\uff0c\u6ce8\u610f\u5728\u5f15\u7528\u7684\u65f6\u5019\u4f7f\u7528\u53cc\u5f15\u53f7\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"307\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/18-9.png\" alt=\"\" class=\"wp-image-1376\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/18-9.png 599w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/18-9-300x154.png 300w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e5f\u53ef\u4ee5\u5c06\u6d4b\u8bd5\u547d\u4ee4\u4e0e\u8f93\u51fa\u547d\u4ee4\u653e\u5728\u4e00\u8d77\u4e66\u5199\uff0c\u4e2d\u95f4\u901a\u8fc7&amp;&amp;\u8fde\u63a5\uff0c<strong>\u8868\u793a\u524d\u9762\u7684\u6267\u884c\u6210\u529f\u624d\u4f1a\u6267\u884c\u540e\u9762\u547d\u4ee4<\/strong>\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"564\" height=\"159\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/37.png\" alt=\"\" class=\"wp-image-5322\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/37.png 564w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/37-300x85.png 300w\" sizes=\"auto, (max-width: 564px) 100vw, 564px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6574\u6570\u6bd4\u8f83\u8fd0\u7b97\u7b26\u4e0d\u9002\u7528\u6d6e\u70b9\u6570\u7684\u6bd4\u8f83\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"215\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/16-7.png\" alt=\"\" class=\"wp-image-1373\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/16-7.png 600w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/16-7-300x108.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center has-medium-font-size wp-block-paragraph\"><strong>\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26\u7528\u6765\u6d4b\u8bd5\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\uff0c\u4e24\u4e2a\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\u6216\u8005\u4e0d\u76f8\u7b49\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26\u53ca\u5176\u542b\u4e49<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u5b57\u7b26\u4e32\u8fd0\u7b97\u7b26<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u542b\u4e49<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">string<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u5b57\u7b26\u4e32string\u662f\u5426\u4e0d\u4e3a\u7a7a<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">==<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u53ea\u662f\u7528\u6765\u5224\u65ad\u76f8\u7b49<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-n string<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u5b57\u7b26\u4e32string\u662f\u5426\u4e0d\u4e3a\u7a7a<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-z string<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u5b57\u7b26\u4e32string\u662f\u5426\u4e3a\u7a7a<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">string1 = string2<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5b57\u7b26\u4e32string1\u662f\u5426\u4e0estring2\u76f8\u540c\uff0c =&nbsp;\u9664\u4e86\u53ef\u7528\u4e8e\u5224\u65ad\u53d8\u91cf\u662f\u5426\u76f8\u7b49\u5916\uff0c\u8fd8\u53ef\u4ee5\u8868\u793a\u8d4b\u503c <\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">string1 != string2<\/td><td class=\"has-text-align-center\" data-align=\"center\"> \u6d4b\u8bd5\u5b57\u7b26\u4e32string1\u662f\u5426\u4e0e\u5b57\u7b26\u4e32string2\u4e0d\u76f8\u540c <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b57\u7b26\u4e32\u6bd4\u8f83\u7684\u65f6\u5019\uff0c\u5efa\u8bae\u4f7f\u7528\u53cc\u5f15\u53f7\uff0c\u5373\u4f7f\u53d8\u91cf\u4e3a\u7a7a\uff0c\u4e5f\u8981\u4f7f\u7528\u53cc\u5f15\u53f7\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"603\" height=\"292\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/17-5.png\" alt=\"\" class=\"wp-image-1374\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/17-5.png 603w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/17-5-300x145.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/17-5-600x291.png 600w\" sizes=\"auto, (max-width: 603px) 100vw, 603px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u6bd4\u8f83\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\uff0c\u8bbe\u7f6e\u4e24\u4e2a\u5b57\u7b26\u4e32\u53d8\u91cfvar1\u548cvar2\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"224\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/19-7.png\" alt=\"\" class=\"wp-image-1377\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/19-7.png 599w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/19-7-300x112.png 300w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f16\u5199\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u8981\u6ce8\u610f\u7a7a\u683c\u95ee\u9898\uff0c\u7a7a\u683c\u4f1a\u9020\u6210\u6d4b\u8bd5\u7ed3\u679c\u4e0d\u76f8\u7b49\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"244\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/21-10.png\" alt=\"\" class=\"wp-image-1378\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/21-10.png 602w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/21-10-300x122.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/04\/21-10-600x243.png 600w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">shell\u7f16\u7a0b\u662f\u4e25\u683c\u533a\u5206\u5927\u5c0f\u5199\u7684\uff0chello\u4e0d\u7b49\u4e8eHello,\u5982\u56fe\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"598\" height=\"205\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/22.png\" alt=\"\" class=\"wp-image-1381\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/22.png 598w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/22-300x103.png 300w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b57\u7b26\u4e32\u8d4b\u503c\u548c\u6574\u6570\u8d4b\u503c\u6ca1\u6709\u533a\u522b\uff0c\u5728\u8fdb\u884c\u6574\u6570\u6bd4\u8f83\u7684\u65f6\u5019\uff0c\u4e0d\u8981\u4f7f\u7528\u5b57\u7b26\u4e32\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff0c\u4f7f\u7528\u7684\u8fd0\u7b97\u7b26\u4e0d\u540c\uff0c\u7ed3\u679c\u4e0d\u540c\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"253\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/23.png\" alt=\"\" class=\"wp-image-1382\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/23.png 600w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/23-300x127.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u76f8\u7b49\uff0c\u524d\u9762\u5224\u65ad\u6210\u529f\u624d\u4f1a\u6267\u884c\u540e\u9762\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"551\" height=\"184\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/38.png\" alt=\"\" class=\"wp-image-5325\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/38.png 551w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/38-300x100.png 300w\" sizes=\"auto, (max-width: 551px) 100vw, 551px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528-n\u548c-z\u6765\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\u7684\u65f6\u5019\uff0c\u9700\u8981\u52a0\u53cc\u5f15\u53f7\uff0c\u5426\u5219\u65e0\u6cd5\u51c6\u786e\u5224\u65ad<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f8b\u5982\uff1a\u4e0b\u9762\u4f8b\u5b50\u4e2d\uff0c\u6ca1\u6709\u5b9a\u4e49\u4efb\u4f55\u53d8\u91cf\uff0c\u76f4\u63a5\u901a\u8fc7-n\u548c-z\u5224\u65ad\u53ef\u4ee5\u53d1\u73b0\u90fd\u662f\u6210\u529f\u7684\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"587\" height=\"149\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/39.png\" alt=\"\" class=\"wp-image-5326\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/39.png 587w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/39-300x76.png 300w\" sizes=\"auto, (max-width: 587px) 100vw, 587px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u7684\u662f\u52a0\u4e86\u53cc\u5f15\u53f7\u4e4b\u540e\u53ef\u4ee5\u770b\u5230\u80fd\u591f\u51c6\u786e\u5224\u65ad\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"597\" height=\"148\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/40.png\" alt=\"\" class=\"wp-image-5327\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/40.png 597w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/40-300x74.png 300w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f7f\u7528\u4e86[[]]\uff0c\u90a3\u4e48\u5c31\u4e0d\u7528\u518d\u4f7f\u7528\u53cc\u5f15\u53f7\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"579\" height=\"138\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/1.png\" alt=\"\" class=\"wp-image-5328\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/1.png 579w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/1-300x72.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center has-medium-font-size wp-block-paragraph\"><strong>\u6587\u4ef6\u64cd\u4f5c\u7b26\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">shell\u63d0\u4f9b\u4e86\u5927\u91cf\u7684\u6587\u4ef6\u64cd\u4f5c\u7b26\uff0c\u8fd9\u6837\u53ef\u4ee5\u5b8c\u6210\u6587\u4ef6\u7684\u5404\u79cd\u6d4b\u8bd5\u5de5\u4f5c\uff0c\u5e38\u7528\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>test  \u6587\u4ef6\u64cd\u4f5c\u7b26   \u6587\u4ef6<\/li><li>[ \u6587\u4ef6\u64cd\u4f5c\u7b26   \u6587\u4ef6 ]<\/li><\/ol>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>\u5e38\u7528\u6587\u4ef6\u64cd\u4f5c\u7b26\u4ee5\u53ca\u542b\u4e49\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u6587\u4ef6\u64cd\u4f5c\u7b26<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u542b\u4e49<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-d file<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u6587\u4ef6\u662f\u5426\u4e3a\u76ee\u5f55<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-e file<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u6587\u4ef6\u662f\u5426\u5b58\u5728<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-f file<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u6587\u4ef6\u662f\u5426\u4e3a\u666e\u901a\u6587\u4ef6<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-r file<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u6587\u4ef6\u662f\u5426\u662f\u8fdb\u7a0b\u53ef\u8bfb\u6587\u4ef6<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-s file<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u6587\u4ef6\u957f\u5ea6\u662f\u5426\u4e0d\u4e3a0<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-w file<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u6587\u4ef6\u662f\u5426\u662f\u8fdb\u7a0b\u53ef\u5199\u6587\u4ef6<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-x file<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u6587\u4ef6\u662f\u5426\u662f\u8fdb\u7a0b\u53ef\u6267\u884c\u6587\u4ef6<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-L file<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6d4b\u8bd5\u6587\u4ef6\u662f\u5426\u662f\u7b26\u53f7\u94fe\u63a5\u6587\u4ef6<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f8b\u5982\uff0c\u6d4b\u8bd5\u6587\u4ef6\u5939abc\u4ee5\u53ca\u6587\u4ef6aa.txt\u662f\u5426\u5b58\u5728\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"329\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/24.png\" alt=\"\" class=\"wp-image-1383\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/24.png 602w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/24-300x164.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/24-600x328.png 600w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u6d4b\u8bd5\u4e00\u4e0b\u6587\u4ef6\u7684\u6743\u9650\u60c5\u51b5\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"282\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/25.png\" alt=\"\" class=\"wp-image-1384\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/25.png 601w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/25-300x141.png 300w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center has-medium-font-size wp-block-paragraph\"><strong>\u903b\u8f91\u8fd0\u7b97\u7b26\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4e8e\u6d4b\u8bd5\u591a\u4e2a\u6761\u4ef6\u662f\u5426\u4e3a\u771f\u6216\u8005\u5047<\/p>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>\u903b\u8f91\u8fd0\u7b97\u7b26\u53ca\u5176\u542b\u4e49\u5982\u4e0b\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u903b\u8f91\u8fd0\u7b97\u7b26<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u542b\u4e49<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">! expression<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5982\u679cexpression\u4e3a\u771f\uff0c\u6d4b\u8bd5\u7ed3\u679c\u4e3a\u5047<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">expression1 -a expression2<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5982\u679cexpression1\u548c2\u540c\u65f6\u4e3a\u771f\uff0c\u90a3\u4e48\u7ed3\u679c\u4e3a\u771f<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">expression1 -o expression2<\/td><td class=\"has-text-align-center\" data-align=\"center\"> \u5982\u679cexpression1\u548c2\u6709\u4e00\u4e2a\u4e3a\u771f\uff0c\u7ed3\u679c\u4e3a\u771f <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\"><strong>\u903b\u8f91\u8fd0\u7b97\u7b26\u771f\u5047\u8868<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">expr1<\/td><td class=\"has-text-align-center\" data-align=\"center\">exp2<\/td><td class=\"has-text-align-center\" data-align=\"center\">!exp1<\/td><td class=\"has-text-align-center\" data-align=\"center\">!exp2<\/td><td class=\"has-text-align-center\" data-align=\"center\">expr1 -a expr2<\/td><td class=\"has-text-align-center\" data-align=\"center\">expr1 -o expr2<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u771f<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u5047<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"251\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/26-1.png\" alt=\"\" class=\"wp-image-1411\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/26-1.png 608w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/26-1-300x124.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/26-1-600x248.png 600w\" sizes=\"auto, (max-width: 608px) 100vw, 608px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center has-medium-font-size wp-block-paragraph\"><strong>\u903b\u8f91\u5224\u65ad\u7b26<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u5224\u65ad\u7b26<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u63cf\u8ff0<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">&amp;&amp;<\/td><td class=\"has-text-align-center\" data-align=\"center\"> \u903b\u8f91\u548c\uff0c\u5728[[]]\u548c(())\u8868\u8fbe\u5f0f\u4e2d\u6216\u5224\u65ad\u8868\u8fbe\u5f0f\u662f\u5426\u4e3a\u771f\u65f6\u4f7f\u7528 <\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">||<\/td><td class=\"has-text-align-center\" data-align=\"center\"> \u903b\u8f91\u6216\uff0c\u5728[[]]\u548c(())\u8868\u8fbe\u5f0f\u4e2d \u6216\u5224\u65ad\u8868\u8fbe\u5f0f\u662f\u5426\u4e3a\u771f\u65f6\u4f7f\u7528 <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"597\" height=\"182\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/2.png\" alt=\"\" class=\"wp-image-5332\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/2.png 597w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/2-300x91.png 300w\" sizes=\"auto, (max-width: 597px) 100vw, 597px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"585\" height=\"172\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/3.png\" alt=\"\" class=\"wp-image-5333\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/3.png 585w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/3-300x88.png 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center has-medium-font-size wp-block-paragraph\"><strong>\u5224\u65ad\uff1a<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u8c13\u5224\u65ad\u5c31\u662f\u5bf9\u8bed\u53e5\u4e2d\u7684\u4e0d\u540c\u6761\u4ef6\u8fdb\u884c\u6d4b\u8bd5\uff0c\u4ece\u800c\u6267\u884c\u4e0d\u540c\u7684\u547d\u4ee4\uff0c\u4f8b\u5982if\/else\u8bed\u53e5\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"603\" height=\"223\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/27-1.png\" alt=\"\" class=\"wp-image-1412\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/27-1.png 603w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/27-1-300x111.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/27-1-600x222.png 600w\" sizes=\"auto, (max-width: 603px) 100vw, 603px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u56fe\u4e2d\u5224\u65ad10\u662f\u5426\u5c0f\u4e8e12\uff0c\u5982\u679c\u6210\u7acb\uff0c\u6253\u5370\u5c0f\u4e8e12\uff0c\u5426\u5219\u5927\u4e8e12\uff0c\u56fe\u4e2d\u7684\u4e2d\u62ec\u53f7\u540e\u5982\u679c\u76f4\u63a5\u52a0then\uff0c\u6b64\u65f6\u9700\u8981\u5728\u4e2d\u62ec\u53f7\u548cthen\u4e4b\u95f4\u52a0\u5206\u53f7\uff1b\u5982\u679c\u4e0d\u52a0\u53ef\u4ee5\u5c06then\u5199\u5728\u4e0b\u9762\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"224\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/28-1.png\" alt=\"\" class=\"wp-image-1413\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/28-1.png 601w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/28-1-300x112.png 300w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/figure>\n\n\n\n<p class=\"has-normal-font-size wp-block-paragraph\"><strong>exit\u547d\u4ee4\u4e00\u822c\u4f34\u968f\u7740\u547d\u4ee4\u7ed3\u675f\uff0c\u8868\u793a\u4e00\u4e2a\u9000\u51fa\u72b6\u6001\uff0c\u5982\u56fe\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"605\" height=\"259\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/29.png\" alt=\"\" class=\"wp-image-1414\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/29.png 605w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/29-300x128.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/29-600x257.png 600w\" sizes=\"auto, (max-width: 605px) 100vw, 605px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u8ff0\u547d\u4ee4\u4e2d\uff0c<strong>read\u8868\u793a\u8bfb\u53d6\u4e00\u4e2a\u952e\u76d8\u8f93\u5165\u5185\u5bb9<\/strong>\uff0c\u5224\u65ad\u662f\u5426\u4e3a\u7a7a\uff0c\u5982\u679c\u4e3a\u7a7a\uff0c\u9000\u51fa\u72b6\u60011\uff0c\u5426\u5219\u4e3a0<\/p>\n\n\n\n<p class=\"has-pale-cyan-blue-background-color has-background wp-block-paragraph\">\u6ce8\u610f\uff1a\u9000\u51fa\u72b6\u6001\u53ef\u4ee5\u81ea\u884c\u6307\u5b9a\u7684\uff0c\u7279\u5b9a\u7684\u503c\u90fd\u6709\u7279\u5b9a\u7684\u7528\u9014\uff0c\u4e0d\u8981\u4e71\u7528<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"241\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/30.png\" alt=\"\" class=\"wp-image-1415\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/30.png 599w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/30-300x121.png 300w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u56fe\u4e2d\uff0c\u7528\u53d8\u91cf$1\u8868\u793a\u7528\u6237\u8f93\u5165\u7684\u5b57\u7b26\u4e32\uff0c\u6b64\u5b57\u7b26\u4e32\u8868\u793a\u4e00\u4e2a\u6587\u4ef6\uff0c\u7136\u540e\u8fdb\u884c\u5224\u65ad\u6587\u4ef6\u662f\u5426\u5b58\u5728\uff0c\u5982\u679c\u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u9000\u51fa\u72b6\u60011\uff0c\u5426\u5219\u5b58\u5728\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>if\/else\u4e5f\u7ecf\u5e38\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\uff0c\u5982\u56fe\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"602\" height=\"346\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/31.png\" alt=\"\" class=\"wp-image-1416\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/31.png 602w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/31-300x172.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/31-600x345.png 600w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u56fe\u4e2d-z\u8868\u793a\u6d4b\u8bd5\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u7a7a\uff0c\uff01\u8868\u793a\u975e\u7a7a\uff0c\u5982\u679c\u975e\u7a7a\uff0c\u90a3\u4e48\u6253\u5370\u4e0d\u662f\u7a7a\uff0c\u518d\u6b21\u8fdb\u884c\u5224\u65ad\u6587\u4ef6\u662f\u5426\u5b58\u5728\uff0c\u5982\u679c\u5b58\u5728\u6253\u5370\u5b58\u5728\uff0c\u53cd\u4e4b\u4e0d\u5b58\u5728\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u63a5\u4e0b\u6765\u770b\u4e00\u7ec4if\/elif\/else\u7684\u4f8b\u5b50\uff0c\u5982\u56fe\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"599\" height=\"303\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/32.png\" alt=\"\" class=\"wp-image-1417\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/32.png 599w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/32-300x152.png 300w\" sizes=\"auto, (max-width: 599px) 100vw, 599px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f\uff0c\u5728\u4e0a\u56fe\u4e2d\uff0cfi\u53ea\u9700\u8981\u5728\u7ed3\u5c3e\u51fa\u73b0\u4e00\u6b21\u5c31\u53ef\u4ee5\u5566\uff0c\u5176\u4f59\u5730\u65b9\u4e0d\u7528<\/p>\n\n\n\n<p class=\"has-text-align-center has-medium-font-size wp-block-paragraph\"><strong>case\u7ed3\u6784<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">case\u547d\u4ee4\u5e38\u7528\u4e8e\u591a\u5206\u652f\u8bed\u53e5\uff0c\u5e38\u6839\u636e\u8868\u8fbe\u5f0f\u7684\u503c\u6765\u9009\u62e9\u8981\u6267\u884c\u7684\u8bed\u53e5<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"601\" height=\"289\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/33.png\" alt=\"\" class=\"wp-image-1418\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/33.png 601w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/33-300x144.png 300w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u56fe\u4e2d\u53d8\u91cf$1\u8868\u793a\u4f20\u5165\u7684\u53c2\u6570\uff0c\u5728\u6267\u884c\u811a\u672c\u7684\u65f6\u5019\u52a0\u5165\u53c2\u6570\uff0c\u5982\u679c\u5339\u914d1\u90a3\u4e48\u6253\u5370\u503c\u4e3a1,\u4ee5\u6b64\u7c7b\u63a8\uff0c\u5982\u679c\u90fd\u4e0d\u5339\u914d\uff0c\u5219\u6253\u5370*\u914d\u7f6e\u7684\u5185\u5bb9\uff0c\u503c\u672a\u77e5\uff0c\u6ce8\u610f\u6700\u540e\u8981\u4ee5esac\u7ed3\u5c3e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u56fe\u4e2d\u8868\u793a\u6839\u636e\u8f93\u5165\u4e0d\u540c\u53c2\u6570\uff0c\u8f93\u51fa\u4e0d\u540c\u5185\u5bb9\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"705\" height=\"176\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2022\/04\/1.png\" alt=\"\" class=\"wp-image-7948\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2022\/04\/1.png 705w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2022\/04\/1-300x75.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2022\/04\/1-600x150.png 600w\" sizes=\"auto, (max-width: 705px) 100vw, 705px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u9762\u4f8b\u5b50\u8868\u793a\u4f7f\u7528case\u7ed3\u6784\u914d\u5408for\u5faa\u73af\u6765\u5b9e\u73b0\u6e05\u7406elk\u7d22\u5f15\u4ee5\u53ca\u6570\u636e\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n: '\n @function: clean elk log\n @author: gongguan\n @date: 2022-04-01\n @\u8bf4\u660e: \u672c\u4f8b\u5b50\u4e2d\u53ea\u5199\u51fa\u4e862022\u5e74\u7684\uff0c\u540e\u7eed\u53ef\u4ee5\u7ee7\u7eed\u6269\u5c55\u52302023\u30012024\u5e74\u7b49\uff0c\u6e05\u7406\u65f6\u5019\u6839\u636e\u63d0\u793a\u8f93\u5165\u5e74\u4efd\n \u548c\u6708\u4efd\u5373\u53ef\n'\ncleanLog(){\n  for i in $(curl 'localhost:9200\/_cat\/indices?v' | awk '{print $3}')\n  do\n    result=$(echo $i | grep ''${month}'')\n    if &#91; -n \"${result}\" ];then\n      curl -XDELETE http:\/\/localhost:9200\/${result}\n    fi\n\n  done\n}\nread -p \"\u8bf7\u8f93\u5165\u8981\u6e05\u695a\u7684\u5e74\u4efd(2022\/2023):\" year\ncase $year in\n2022)\n  read -p \"\u8bf7\u8f93\u5165\u8981\u6e05\u9664\u7684\u6708\u4efd(01\/02\/03....):\" month\n  case $month in\n  01)\n   cleanLog\n   ;;\n  02)\n   cleanLog\n   ;;\n   03)\n   cleanLog\n   ;;\n   04)\n   cleanLog\n   ;;\n   05)\n   cleanLog\n   ;;\n    06)\n   cleanLog\n   ;;\n   07)\n   cleanLog\n   ;;\n   08)\n   cleanLog\n   ;;\n   09)\n   cleanLog\n   ;;\n   10)\n   cleanLog\n   ;;\n   01)\n   cleanLog\n   ;;\n   12)\n   cleanLog\n   ;;\n   *)\n    echo \"\u8f93\u5165\u7684\u6708\u4efd\u4e0d\u5339\u914d\"  \n  esac\n;;\n*)\n  echo \"\u5e74\u4efd\u4e0d\u5339\u914d\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165.....\"\n;;\nesac\n<\/code><\/pre>\n\n\n\n<p class=\"has-text-align-center has-medium-font-size wp-block-paragraph\"><strong>\u7b97\u672f\u8fd0\u7b97\u7b26<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u8fd0\u7b97\u7b26<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u4e3e\u4f8b<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u7ed3\u679c<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">+(\u52a0\u8fd0\u7b97)<\/td><td class=\"has-text-align-center\" data-align=\"center\">3+5<\/td><td class=\"has-text-align-center\" data-align=\"center\">8<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-(\u51cf\u8fd0\u7b97)<\/td><td class=\"has-text-align-center\" data-align=\"center\">5-3<\/td><td class=\"has-text-align-center\" data-align=\"center\">2<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">*(\u4e58\u8fd0\u7b97)<\/td><td class=\"has-text-align-center\" data-align=\"center\">5*3<\/td><td class=\"has-text-align-center\" data-align=\"center\">15<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">\/(\u9664\u8fd0\u7b97)<\/td><td class=\"has-text-align-center\" data-align=\"center\">8\/2<\/td><td class=\"has-text-align-center\" data-align=\"center\">4<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">%(\u53d6\u4f59)<\/td><td class=\"has-text-align-center\" data-align=\"center\">8%3<\/td><td class=\"has-text-align-center\" data-align=\"center\">2<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">**(\u5e42\u8fd0\u7b97)<\/td><td class=\"has-text-align-center\" data-align=\"center\">5**3<\/td><td class=\"has-text-align-center\" data-align=\"center\">125<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001\u5728\u8fdb\u884c\u6574\u6570\u8fd0\u7b97\u7684\u65f6\u5019\uff0c\u6700\u7ec8\u7ed3\u679c\u5c06\u662f\u5546\u7684\u6574\u6570\u90e8\u5206\uff0c\u5ffd\u7565\u56db\u820d\u4e94\u5165\uff0c\u5ffd\u7565\u5c0f\u6570\u90e8\u5206\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"590\" height=\"247\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/14-1.png\" alt=\"\" class=\"wp-image-1421\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/14-1.png 590w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/14-1-300x126.png 300w\" sizes=\"auto, (max-width: 590px) 100vw, 590px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u56fe\u4e2d\uff0c9\u96642\u7b49\u4e8e4\uff0c8\u9664\u4ee55\u7b49\u4e8e1\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2\u3001\u63a5\u4e0b\u6765\u770b\u4e0b\u53d6\u4f59\u6570\u4ee5\u53ca\u5e42\u8fd0\u7b97\u7684\u4f8b\u5b50\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"592\" height=\"252\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/15-1.png\" alt=\"\" class=\"wp-image-1422\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/15-1.png 592w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/15-1-300x128.png 300w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/figure>\n\n\n\n<p class=\"has-pale-cyan-blue-background-color has-background wp-block-paragraph\">\u6ce8\u610f\uff1a\u5728\u9664\u6cd5\u4ee5\u53ca\u53d6\u4f59\u7684\u8fc7\u7a0b\u4e2d\uff0c\u9664\u6570\u4e0d\u80fd\u4e3a0\uff0c\u5426\u5219\u4f1a\u62a5\u9519\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> <strong>\u8fd0\u7b97\u8868\u8fbe\u5f0f\uff1a<\/strong> <\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"> \u8868\u8fbe\u5f0f <\/td><td class=\"has-text-align-center\" data-align=\"center\"> \u793a\u4f8b <\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">  $(())  <\/td><td class=\"has-text-align-center\" data-align=\"center\">  $(())  <\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"> $[] <\/td><td class=\"has-text-align-center\" data-align=\"center\">  $[1+1]  <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u9664\u4e86\u4f7f\u7528let\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7<strong>$[]<\/strong>\u6216\u8005<strong>$(())<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3\u3001<strong>\u4e0b\u9762\u811a\u672c\u4f8b\u5b50\u901a\u8fc7$[] \u6765\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97<\/strong>\uff0c\u5faa\u73af\u6267\u884c10\u6b21\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"544\" height=\"161\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/31-2.png\" alt=\"\" class=\"wp-image-5291\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/31-2.png 544w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/31-2-300x89.png 300w\" sizes=\"auto, (max-width: 544px) 100vw, 544px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6267\u884c\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"181\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/32-2.png\" alt=\"\" class=\"wp-image-5292\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/32-2.png 525w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/32-2-300x103.png 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"> 4\u3001<strong>\u4e0b\u9762\u811a\u672c\u4f8b\u5b50\u901a\u8fc7$(()) \u6765\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97<\/strong>\uff0c\u5faa\u73af\u6267\u884c10\u6b21\uff0c\u5982\u56fe\uff1a <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"552\" height=\"163\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/33-1.png\" alt=\"\" class=\"wp-image-5293\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/33-1.png 552w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/33-1-300x89.png 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"181\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/32-3.png\" alt=\"\" class=\"wp-image-5294\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/32-3.png 525w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/10\/32-3-300x103.png 300w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/figure>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background wp-block-paragraph\">\u6ce8\u610f\uff1a$[] \u548c$(()) \u7b49\u6548\uff0c\u63d0\u4f9b\u540c\u6837\u7684\u529f\u80fd\uff0c \u4f46\u662f\u90fd\u4e0d\u652f\u6301\u6d6e\u70b9\u8fd0\u7b97 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> $(())\u8868\u8fbe\u5f0f\u8fd8\u6709\u4e00\u4e2a\u7528\u9014\uff0c<strong>\u4e09\u76ee\u8fd0\u7b97<\/strong>\uff1a <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">5\u3001\u4e0b\u9762\u4f8b\u5b50\uff0c\u5982\u679c\u6761\u4ef6\u4e3a\u771f\u8f93\u51fa1\uff0c\u5426\u5219\u8f93\u51fa0\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"553\" height=\"137\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/9.png\" alt=\"\" class=\"wp-image-5341\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/9.png 553w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/9-300x74.png 300w\" sizes=\"auto, (max-width: 553px) 100vw, 553px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">6\u3001\u4e0b\u9762\u4f8b\u5b50\uff0c\u5982\u679c\u6761\u4ef6\u4e3a\u771f\uff0c\u8f93\u51fa\u5192\u53f7\u524d\u9762\u7684\u6570\u5b57\uff0c\u5426\u5219\u8f93\u51fa\u540e\u9762\u7684\u6570\u5b57\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"528\" height=\"127\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/10.png\" alt=\"\" class=\"wp-image-5343\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/10.png 528w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/10-300x72.png 300w\" sizes=\"auto, (max-width: 528px) 100vw, 528px\" \/><\/figure>\n\n\n\n<p class=\"has-luminous-vivid-amber-background-color has-background wp-block-paragraph\"> \u6ce8\u610f\uff1a\u8fd4\u56de\u503c\u4e0d\u652f\u6301\u5b57\u7b26\u4e32<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5176\u4ed6\u8fd0\u7b97\u5de5\u5177\uff08let\/expr\/bc\uff09 <\/strong>\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> \u9664\u4e86 Shell \u672c\u8eab\u7684\u7b97\u6570\u8fd0\u7b97\u8868\u8fbe\u5f0f\uff0c\u8fd8\u6709\u51e0\u4e2a\u547d\u4ee4\u652f\u6301\u590d\u6742\u7684\u7b97\u6570\u8fd0\u7b97\uff1a <\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"> <strong>\u547d\u4ee4<\/strong> <\/td><td class=\"has-text-align-center\" data-align=\"center\"> <strong>\u63cf\u8ff0<\/strong> <\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"> let <\/td><td class=\"has-text-align-center\" data-align=\"center\"> \u8d4b\u503c\u5e76\u8fd0\u7b97\uff0c\u652f\u6301++\u3001&#8211; <\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"> expr <\/td><td class=\"has-text-align-center\" data-align=\"center\"> \u4e58\u6cd5*\u9700\u8981\u52a0\u53cd\u659c\u6760\u8f6c\u4e49\\* <\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"> bc  <\/td><td class=\"has-text-align-center\" data-align=\"center\"> \u8ba1\u7b97\u5668\uff0c\u652f\u6301\u6d6e\u70b9\u8fd0\u7b97\u3001  \u5e73\u65b9\u7b49 <\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#let\u547d\u4ee4\u7684\u4f8b\u5b50\u5982\u4e0b\uff1a\nlet VAR=(1+2)*3 ; echo $VAR\nx=10 ; y=5\nlet x++;echo $x \u6bcf\u6267\u884c\u4e00\u6b21 x \u52a0 1\nlet y--;echo $y \u6bcf\u6267\u884c\u4e00\u6b21 y \u51cf 1\nlet x+=2 \u6bcf\u6267\u884c\u4e00\u6b21 x \u52a0 2\nlet x-=2 \u6bcf\u6267\u884c\u4e00\u6b21 x \u51cf 2\n\n#expr\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a\nexpr 1 \\* 2 \u8fd0\u7b97\u7b26\u4e24\u8fb9\u5fc5\u987b\u6709\u7a7a\u683c\nexpr \\( 1 + 2 \\) \\* 2 \u4f7f\u7528\u53cc\u62ec\u53f7\u65f6\u8981\u8f6c\u4e49\n\n#bc\u547d\u4ee4\u793a\u4f8b\u5982\u4e0b\uff1a\nbc \u672c\u8eab\u5c31\u662f\u4e00\u4e2a\u8ba1\u7b97\u5668\uff0c\u53ef\u76f4\u63a5\u8f93\u5165\u547d\u4ee4\uff0c\u8fdb\u5165\u89e3\u91ca\u5668\u3002\necho 1 + 2 |bc \u5c06\u7ba1\u9053\u7b26\u524d\u9762\u6807\u51c6\u8f93\u51fa\u4f5c\u4e3a bc \u7684\u6807\u51c6\u8f93\u5165\necho \"1.2+2\" |bc\necho \"10^10\" |bc\necho 'scale=2;10\/3' |bc \u7528 scale \u4fdd\u7559\u4e24\u4f4d\u5c0f\u6570\u70b9<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> \u7531\u4e8e Shell \u4e0d\u652f\u6301\u6d6e\u70b9\u6570\u6bd4\u8f83\uff0c\u53ef\u4ee5\u501f\u52a9 bc \u6765\u5b8c\u6210\u9700\u6c42\uff1a <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"559\" height=\"215\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/11.png\" alt=\"\" class=\"wp-image-5347\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/11.png 559w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2021\/11\/11-300x115.png 300w\" sizes=\"auto, (max-width: 559px) 100vw, 559px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u56fe\u4e2d\u8fd0\u7b97\u5982\u679c\u4e3a\u771f\u8fd4\u56de 1\uff0c\u5426\u5219\u8fd4\u56de 0 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">7\u3001\u4e0b\u9762\u4f8b\u5b50\u8868\u793a\u901a\u8fc7bc\u8ba1\u7b97\u9664\u6cd5\uff0c\u5e76\u4fdd\u7559\u4e24\u4f4d\u5c0f\u6570\uff0c\u5982\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"303\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2022\/10\/6-3.png\" alt=\"\" class=\"wp-image-10415\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2022\/10\/6-3.png 710w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2022\/10\/6-3-300x128.png 300w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2022\/10\/6-3-600x256.png 600w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center has-medium-font-size wp-block-paragraph\"><strong>\u7b97\u672f\u590d\u5408\u8fd0\u7b97\u7b26<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u8fd0\u7b97\u7b26<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u4e3e\u4f8b<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u7b49\u4ef7\u8868\u8fbe\u5f0f<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">+=<\/td><td class=\"has-text-align-center\" data-align=\"center\">a+=5<\/td><td class=\"has-text-align-center\" data-align=\"center\">a=a+5<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">-=<\/td><td class=\"has-text-align-center\" data-align=\"center\">a-=5<\/td><td class=\"has-text-align-center\" data-align=\"center\">a=a-5<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">*=<\/td><td class=\"has-text-align-center\" data-align=\"center\">a*=5<\/td><td class=\"has-text-align-center\" data-align=\"center\">a=a*5<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">\/=<\/td><td class=\"has-text-align-center\" data-align=\"center\">a\/=3<\/td><td class=\"has-text-align-center\" data-align=\"center\">a=a\/3<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">%=<\/td><td class=\"has-text-align-center\" data-align=\"center\">a%=5<\/td><td class=\"has-text-align-center\" data-align=\"center\">a=a%5<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"261\" src=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/16-1.png\" alt=\"\" class=\"wp-image-1423\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/16-1.png 600w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/05\/16-1-300x131.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Shell \u62ec\u53f7\u7528\u9014\u603b\u7ed3\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>\u547d\u4ee4<\/td><td>\u7528\u9014<\/td><\/tr><tr><td>()<\/td><td>\u7528\u9014 1\uff1a\u5728\u8fd0\u7b97\u4e2d\uff0c\u5148\u8ba1\u7b97\u5c0f\u62ec\u53f7\u91cc\u9762\u7684\u5185\u5bb9 <br>\u7528\u9014 2\uff1a\u6570\u7ec4 <br>\u7528\u9014 3\uff1a\u5339\u914d\u5206\u7ec4 <\/td><\/tr><tr><td>(())<\/td><td> \u7528\u9014 1\uff1a\u8868\u8fbe\u5f0f\uff0c\u4e0d\u652f\u6301-eq \u8fd9\u7c7b\u7684\u8fd0\u7b97\u7b26\u3002\u4e0d\u652f\u6301-a \u548c-o\uff0c\u652f\u6301&lt;=\u3001&gt;=\u3001&lt;\u3001&gt;\u8fd9\u7c7b <br>\u6bd4\u8f83\u7b26\u548c&amp;&amp;\u3001|| <br>\u7528\u9014 2\uff1aC \u8bed\u8a00\u98ce\u683c\u7684 for(())\u8868\u8fbe\u5f0f <\/td><\/tr><tr><td>$()<\/td><td> \u6267\u884c Shell \u547d\u4ee4\uff0c\u4e0e\u53cd\u5f15\u53f7\u7b49\u6548 <\/td><\/tr><tr><td>$(())<\/td><td>\u7528\u9014 1\uff1a\u7b80\u5355\u7b97\u6570\u8fd0\u7b97 <br>\u7528\u9014 2\uff1a\u652f\u6301\u4e09\u76ee\u8fd0\u7b97\u7b26 $(( \u8868\u8fbe\u5f0f?\u6570\u5b57:\u6570\u5b57 )) <\/td><\/tr><tr><td>[]<\/td><td> \u6761\u4ef6\u8868\u8fbe\u5f0f\uff0c\u91cc\u9762\u4e0d\u652f\u6301\u903b\u8f91\u5224\u65ad\u7b26 &amp;&amp;\u3001||\uff0c\u652f\u6301-a\u3001-o<\/td><\/tr><tr><td>[[]]<\/td><td> \u6761\u4ef6\u8868\u8fbe\u5f0f\uff0c\u91cc\u9762\u4e0d\u652f\u6301-a \u548c-o\uff0c\u4e0d\u652f\u6301&lt;=\u548c&gt;=\u6bd4\u8f83\u7b26\uff0c\u652f\u6301-eq\u3001&lt;\u3001&gt;\u8fd9\u7c7b\u6bd4\u8f83 <br>\u7b26\u3002\u652f\u6301=~\u6a21\u5f0f\u5339\u914d\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u7528\u53cc\u5f15\u53f7\u4e5f\u4e0d\u4f1a\u5f71\u54cd\u539f\u610f\uff0c\u6bd4[]\u66f4\u52a0\u901a\u7528 <\/td><\/tr><tr><td>$[]<\/td><td> \u7b80\u5355\u7b97\u6570\u8fd0\u7b97 <\/td><\/tr><tr><td>{}<\/td><td>\u5bf9\u9017\u53f7\uff08,\uff09\u548c\u70b9\u70b9\uff08&#8230;\uff09\u8d77\u4f5c\u7528\uff0c\u6bd4\u5982 touch {1,2}\u521b\u5efa 1 \u548c 2 \u6587\u4ef6\uff0ctouch  {1..3}\u521b\u5efa 1\u30012 \u548c 3 \u6587\u4ef6 <\/td><\/tr><tr><td>${}<\/td><td> \u7528\u9014 1\uff1a\u5f15\u7528\u53d8\u91cf <br>\u7528\u9014 2\uff1a\u5b57\u7b26\u4e32\u5904\u7406 <\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u547d\u4ee4\u6267\u884c\u5b8c\u6210\u540e\u4f1a\u8fd4\u56de\u4e00\u4e2a\u9000\u51fa\u72b6\u6001\uff0c\u5982\u679c\u4e3a0\u8868\u793a\u9000\u51fa\u6210\u529f\uff0c\u5982\u4f55\u4e0d\u4e3a0\uff0c\u8868\u793a\u672a\u6210\u529f\u3002 \u9000\u51fa\u72b6\u6001 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":1424,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,29],"tags":[],"class_list":["post-1369","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-shell","category-yunwei"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/1369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1369"}],"version-history":[{"count":30,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/1369\/revisions"}],"predecessor-version":[{"id":10416,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/1369\/revisions\/10416"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/1424"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}