{"id":43709,"date":"2023-03-16T01:39:39","date_gmt":"2023-03-15T17:39:39","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=43709"},"modified":"2023-03-16T01:39:39","modified_gmt":"2023-03-15T17:39:39","slug":"linux-shell-update","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-shell-update.html","title":{"rendered":"\u5927\u795e\u6559\u4f60\u5982\u4f55\u5728 Linux \u4e2d\u542f\u7528 Shell \u811a\u672c\u7684\u8c03\u8bd5\u6a21\u5f0f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u811a\u672c\u662f\u5b58\u50a8\u5728\u4e00\u4e2a\u6587\u4ef6\u7684\u4e00\u7cfb\u5217\u547d\u4ee4\u3002\u5728\u7ec8\u7aef\u4e0a\u8f93\u5165\u4e00\u4e2a\u4e2a\u547d\u4ee4\uff0c\u6309\u987a\u5e8f\u6267\u884c\u7684\u65b9\u6cd5\u592a\u5f31\u4e86\uff0c\u4f7f\u7528\u811a\u672c\uff0c\u7cfb\u7edf\u4e2d\u7684\u7528\u6237\u53ef\u4ee5\u5728\u4e00\u4e2a\u6587\u4ef6\u4e2d\u5b58\u50a8\u6240\u6709\u547d\u4ee4\uff0c\u53cd\u590d\u8c03\u7528\u8be5\u6587\u4ef6\u591a\u6b21\u91cd\u65b0\u6267\u884c\u547d\u4ee4\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5728\u5b66\u4e60\u811a\u672c\u6216\u5199\u811a\u672c\u7684\u521d\u671f\u9636\u6bb5\uff0c\u6211\u4eec\u901a\u5e38\u4ece\u5199\u5c0f\u811a\u672c\u6216\u8005\u51e0\u884c\u547d\u4ee4\u7684\u77ed\u811a\u672c\u5f00\u59cb\uff0c\u8c03\u8bd5\u8fd9\u6837\u7684\u811a\u672c\u65f6\u6211\u4eec\u901a\u5e38\u65e0\u975e\u5c31\u662f\u901a\u8fc7\u89c2\u5bdf\u5b83\u4eec\u7684\u8f93\u51fa\u6765\u786e\u4fdd\u5176\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n

\"u39866739293700912739fm21gp0\"<\/p>\n

\u7136\u800c\uff0c\u5f53\u6211\u4eec\u5f00\u59cb\u5199\u975e\u5e38\u957f\u6216\u4e0a\u5343\u884c\u547d\u4ee4\u7684\u9ad8\u7ea7\u811a\u672c\uff0c\u4f8b\u5982\u6539\u53d8\u7cfb\u7edf\u8bbe\u7f6e\u7684\u811a\u672c\uff0c\u5728\u7f51\u7edc\u4e0a\u6267\u884c\u5173\u952e\u5907\u4efd \u7b49\u7b49\uff0c\u6211\u4eec\u4f1a\u610f\u8bc6\u5230\u4ec5\u4ec5\u770b\u811a\u672c\u8f93\u51fa\u662f\u4e0d\u8db3\u4ee5\u5728\u811a\u672c\u4e2d\u627e\u5230 Bug \u7684\uff01<\/p>\n

\u56e0\u6b64\uff0c\u5728 Linux \u7cfb\u5217\u4e2d\u8fd9\u7bc7\u4ecb\u7ecd Shell \u811a\u672c\u8c03\u8bd5\uff0c \u6211\u4eec\u5c06\u770b\u770b\u5982\u4f55\u542f\u7528 Shell \u811a\u672c\u8c03\u8bd5\uff0c\u7136\u540e\u5728\u4e4b\u540e\u7684\u7cfb\u5217\u4e2d\u89e3\u91ca\u4e0d\u540c\u7684 Shell \u811a\u672c\u8c03\u8bd5\u6a21\u5f0f\u4ee5\u53ca\u5982\u4f55\u4f7f\u7528\u5b83\u4eec\u3002<\/p>\n

\u5982\u4f55\u5f00\u59cb\u5199\u4e00\u4e2a\u811a\u672c<\/strong><\/div>\n

\u4e00\u4e2a\u811a\u672c\u4e0e\u5176\u5b83\u6587\u4ef6\u7684\u533a\u522b\u662f\u5b83\u7684\u9996\u884c\uff0c\u5b83\u5305\u542b #!<\/span>\uff08She-Bang - \u91ca\u4f34\uff1a\u5b9a\u4e49\u6587\u4ef6\u7c7b\u578b\uff09\u548c\u8def\u5f84\u540d\uff08\u89e3\u91ca\u5668\u8def\u5f84\uff09\uff0c\u901a\u77e5\u7cfb\u7edf\u8be5\u6587\u4ef6\u662f\u4e00\u4e2a\u547d\u4ee4\u96c6\u5408\uff0c\u5c06\u88ab\u6307\u5b9a\u7a0b\u5e8f(\u89e3\u91ca\u5668)\u89e3\u91ca\u3002<\/p>\n

\"u29135855891493614726fm21gp0\"<\/p>\n

\u4e0b\u9762\u662f\u4e0d\u540c\u7c7b\u578b\u811a\u672c\u9996\u884c<\/span>\u793a\u4f8b\uff1a<\/p>\n

#!\/bin\/sh          [sh \u811a\u672c]\r\n#!\/bin\/bash        [bash \u811a\u672c] \r\n#!\/usr\/bin\/perl    [perl \u7a0b\u5e8f]\r\n#!\/bin\/awk -f      [awk \u811a\u672c]   \r\n<\/pre>\n

\u6ce8\u610f\uff1a\u5982\u679c\u811a\u672c\u4ec5\u5305\u542b\u4e00\u7ec4\u6807\u51c6\u7cfb\u7edf\u547d\u4ee4\uff0c\u6ca1\u6709\u4efb\u4f55\u5185\u90e8 Shell \u6307\u4ee4\uff0c\u9996\u884c\u6216#!<\/span>\u53ef\u4ee5\u53bb\u6389\u3002<\/p>\n

\u5982\u4f55\u5728 Linux \u64cd\u4f5c\u7cfb\u7edf\u6267\u884c Shell \u811a\u672c<\/strong><\/div>\n

\u8c03\u7528\u4e00\u4e2a\u811a\u672c\u811a\u672c\u7684\u5e38\u89c4\u8bed\u6cd5\u662f\uff1a<\/p>\n

$ \u811a\u672c\u540d  \u53c2\u65701 ... \u53c2\u6570N\r\n<\/pre>\n

\u53e6\u4e00\u79cd\u53ef\u80fd\u7684\u5f62\u5f0f\u662f\u660e\u786e\u6307\u5b9a\u5c06\u6267\u884c\u8fd9\u4e2a\u811a\u672c\u7684 Shell\uff0c\u5982\u4e0b\uff1a<\/p>\n

$ shell \u811a\u672c\u540d  \u53c2\u65701 ... \u53c2\u6570N\r\n<\/pre>\n

\u793a\u4f8b\uff1a<\/p>\n

$ \/bin\/bash   \u53c2\u65701 ... \u53c2\u6570N     [bash \u811a\u672c]\r\n$ \/bin\/ksh   \u53c2\u65701 ... \u53c2\u6570N      [ksh \u811a\u672c]\r\n$ \/bin\/sh   \u53c2\u65701 ... \u53c2\u6570N       [sh \u811a\u672c]\r\n<\/pre>\n

\u5bf9\u4e8e\u6ca1\u6709 #!<\/span>\u4f5c\u4e3a\u9996\u884c\uff0c\u4ec5\u5305\u542b\u57fa\u7840\u7cfb\u7edf\u547d\u4ee4\u7684\u811a\u672c\uff0c\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n

### \u811a\u672c\u4ec5\u5305\u542b\u6807\u51c6\u7cfb\u7edf\u547d\u4ee4\r\ncd \/home\/$USER\r\nmkdir tmp\r\necho \"tmp directory created under \/home\/$USER\"\r\n<\/pre>\n

\u4f7f\u5b83\u53ef\u6267\u884c\u5e76\u8fd0\u884c\uff0c\u5982\u4e0b\uff1a<\/p>\n

$ chmod +x  \u811a\u672c\u540d\r\n$ .\/\u811a\u672c\u540d \r\n<\/pre>\n
\u542f\u7528 Shell \u811a\u672c\u8c03\u8bd5\u6a21\u5f0f\u7684\u65b9\u6cd5<\/strong><\/div>\n

\"u3394782435989447934fm21gp0\"<\/p>\n

\u4e0b\u9762\u662f\u4e3b\u8981\u7684 Shell \u811a\u672c\u8c03\u8bd5\u9009\u9879\uff1a<\/p>\n