{"id":162083,"date":"2019-11-03T10:00:47","date_gmt":"2019-11-03T02:00:47","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=162083"},"modified":"2019-10-22T09:26:35","modified_gmt":"2019-10-22T01:26:35","slug":"learning-shell-tutorial","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/learning-shell-tutorial.html","title":{"rendered":"\u5b66\u4e60Shell \u6559\u7a0b"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | Shell \u662f\u4e00\u4e2a\u7528 C \u8bed\u8a00\u7f16\u5199\u7684\u7a0b\u5e8f\uff0c\u5b83\u662f\u7528\u6237\u4f7f\u7528 Linux \u7684\u6865\u6881\u3002Shell \u65e2\u662f\u4e00\u79cd\u547d\u4ee4\u8bed\u8a00\uff0c\u53c8\u662f\u4e00\u79cd\u7a0b\u5e8f\u8bbe\u8ba1\u8bed\u8a00\u3002 \nShell \u662f\u6307\u4e00\u79cd\u5e94\u7528\u7a0b\u5e8f\uff0c\u8fd9\u4e2a\u5e94\u7528\u7a0b\u5e8f\u63d0\u4f9b\u4e86\u4e00\u4e2a\u754c\u9762\uff0c\u7528\u6237\u901a\u8fc7\u8fd9\u4e2a\u754c\u9762\u8bbf\u95ee\u64cd\u4f5c\u7cfb\u7edf\u5185\u6838\u7684\u670d\u52a1\u3002 \nKen Thompson \u7684 sh \u662f\u7b2c\u4e00\u79cd Unix Shell\uff0cWindows Explorer \u662f\u4e00\u4e2a\u5178\u578b\u7684\u56fe\u5f62\u754c\u9762 Shell\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n Shell \u811a\u672c<\/strong><\/div>\n Shell \u811a\u672c\uff08shell script\uff09\uff0c\u662f\u4e00\u79cd\u4e3a shell \u7f16\u5199\u7684\u811a\u672c\u7a0b\u5e8f\u3002<\/p>\n \u4e1a\u754c\u6240\u8bf4\u7684 shell \u901a\u5e38\u90fd\u662f\u6307 shell \u811a\u672c\uff0c\u4f46\u8bfb\u8005\u670b\u53cb\u8981\u77e5\u9053\uff0cshell \u548c shell script \u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u6982\u5ff5\u3002<\/p>\n \u7531\u4e8e\u4e60\u60ef\u7684\u539f\u56e0\uff0c\u7b80\u6d01\u8d77\u89c1\uff0c\u672c\u6587\u51fa\u73b0\u7684 \"shell\u7f16\u7a0b\" \u90fd\u662f\u6307 shell \u811a\u672c\u7f16\u7a0b\uff0c\u4e0d\u662f\u6307\u5f00\u53d1 shell \u81ea\u8eab\u3002<\/p>\n Shell \u73af\u5883<\/strong><\/div>\n Shell \u7f16\u7a0b\u8ddf JavaScript\u3001php \u7f16\u7a0b\u4e00\u6837\uff0c\u53ea\u8981\u6709\u4e00\u4e2a\u80fd\u7f16\u5199\u4ee3\u7801\u7684\u6587\u672c\u7f16\u8f91\u5668\u548c\u4e00\u4e2a\u80fd\u89e3\u91ca\u6267\u884c\u7684\u811a\u672c\u89e3\u91ca\u5668\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n Linux \u7684 Shell \u79cd\u7c7b\u4f17\u591a\uff0c\u5e38\u89c1\u7684\u6709\uff1a<\/p>\n Bourne Shell\uff08\/usr\/bin\/sh\u6216\/bin\/sh\uff09 \u5728\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u4eba\u4eec\u5e76\u4e0d\u533a\u5206 Bourne Shell \u548c Bourne Again Shell\uff0c\u6240\u4ee5\uff0c\u50cf #!\/bin\/sh\uff0c\u5b83\u540c\u6837\u4e5f\u53ef\u4ee5\u6539\u4e3a #!\/bin\/bash\u3002<\/p>\n #! \u544a\u8bc9\u7cfb\u7edf\u5176\u540e\u8def\u5f84\u6240\u6307\u5b9a\u7684\u7a0b\u5e8f\u5373\u662f\u89e3\u91ca\u6b64\u811a\u672c\u6587\u4ef6\u7684 Shell \u7a0b\u5e8f\u3002<\/p>\n \u7b2c\u4e00\u4e2ashell\u811a\u672c<\/strong><\/div>\n \u6253\u5f00\u6587\u672c\u7f16\u8f91\u5668(\u53ef\u4ee5\u4f7f\u7528 vi\/vim \u547d\u4ee4\u6765\u521b\u5efa\u6587\u4ef6)\uff0c\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6 test.sh\uff0c\u6269\u5c55\u540d\u4e3a sh\uff08sh\u4ee3\u8868shell\uff09\uff0c\u6269\u5c55\u540d\u5e76\u4e0d\u5f71\u54cd\u811a\u672c\u6267\u884c\uff0c\u89c1\u540d\u77e5\u610f\u5c31\u597d\uff0c\u5982\u679c\u4f60\u7528 php \u5199 shell \u811a\u672c\uff0c\u6269\u5c55\u540d\u5c31\u7528 php \u597d\u4e86\u3002<\/p>\n \u8f93\u5165\u4e00\u4e9b\u4ee3\u7801\uff0c\u7b2c\u4e00\u884c\u4e00\u822c\u662f\u8fd9\u6837\uff1a<\/p>\n \u5b9e\u4f8b\r\n#!\/bin\/bash\r\necho \"Hello World !\"\r\n\r\n\u8fd0\u884c\u5b9e\u4f8b \u00bb<\/pre>\n |