{"id":1718,"date":"2024-04-20T08:00:51","date_gmt":"2024-04-20T08:00:51","guid":{"rendered":"https:\/\/howtogeek.blog\/zh\/?p=1718"},"modified":"2024-04-20T08:00:51","modified_gmt":"2024-04-20T08:00:51","slug":"how-to-run-a-shell-script-on-mac-zh-tw","status":"publish","type":"post","link":"https:\/\/howtogeek.blog\/zh\/how-to-run-a-shell-script-on-mac-zh-tw\/","title":{"rendered":"\u5982\u4f55\u5728 Mac \u4e0a\u57f7\u884c Shell \u8173\u672c"},"content":{"rendered":"<p>\u5728 Mac \u4e0a\u5b89\u88dd\u61c9\u7528\u7a0b\u5f0f\u76f8\u5c0d\u5bb9\u6613\uff0c\u5f88\u5c11\u9700\u8981\u91cd\u65b0\u555f\u52d5\u3002\u5927\u591a\u6578\u4eba\u5c07\u61c9\u7528\u7a0b\u5f0f\u5716\u793a\u62d6\u653e\u5230\u300c\u61c9\u7528\u7a0b\u5f0f\u300d\u8cc7\u6599\u593e\u4e2d\uff0c\u4f46\u66f8\u5446\u5b50\u4f7f\u7528 shell \u8173\u672c\u3002\u60a8\u4e5f\u53ef\u4ee5\u5728 Mac \u4e0a\u7684<a href=\"https:\/\/support.apple.com\/en-in\/guide\/terminal\/apd53500956-7c5b-496b-a362-2845f2aab4bc\/mac\" rel=\"noreferrer noopener\" target=\"_blank\">\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u8f15\u9b06\u57f7\u884c shell \u8173\u672c<\/a>\uff0c\u524d\u63d0\u662f\u60a8\u8981\u7262\u8a18\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9805\u3002\u5c0d\u65bc\u521d\u5b78\u8005\u4f86\u8aaa\uff0c\u907f\u514d\u904b\u884c\u60a8\u5728\u7dda\u4e0b\u8f09\u7684\u8173\u672c\u800c\u4e0d\u77e5\u9053\u5b83\u53ef\u4ee5\u505a\u4ec0\u9ebc\u3002\u56e0\u6b64\uff0c\u5728 Mac \u4e0a\u904b\u884c shell \u8173\u672c\u6709\u5169\u7a2e\u65b9\u6cd5\u2014\u2014\u7c21\u55ae\u65b9\u6cd5\u548c\u5b89\u5168\u65b9\u6cd5\u3002<\/p>\n<h2><span id=\"Things-You-Need-to-Know-About-Shell-Scripts\">\u95dc\u65bc Shell \u8173\u672c\u60a8\u9700\u8981\u4e86\u89e3\u7684\u4e8b\u60c5<\/span><\/h2>\n<p>shell \u662f\u4e00\u7a2e\u57fa\u65bc\u6587\u5b57\u7684\u4e92\u52d5\u5f0f\u4ecb\u9762\uff0c\u53ef\u8207\u547d\u4ee4\u4e00\u8d77\u4f7f\u7528\u3002\u56e0\u6b64\uff0cshell \u8173\u672c\u5c31\u50cf\u4e00\u500b\u5305\u542b\u591a\u500b\u547d\u4ee4\u7684\u6587\u5b57\u6587\u4ef6\uff0c\u53ef\u5e6b\u52a9\u60a8\u907f\u514d\u70ba\u91cd\u8907\u4efb\u52d9\u91cd\u65b0\u8f38\u5165\u5b83\u5011\u3002\u9019\u6a23\u60a8\u5c31\u53ef\u4ee5\u5c07\u591a\u500b\u4efb\u52d9\u5408\u4f75\u5230\u4e00\u500b\u8173\u672c\u4e2d\uff0c\u4ee5\u7bc0\u7701\u6642\u9593\u4e26\u907f\u514d\u91cd\u8907\u4efb\u52d9\u6240\u9020\u6210\u7684\u932f\u8aa4\u3002 shell\u8173\u672c\u651c\u5e36\u7684\u6a94\u6848\u540d\u7a31\u3002 SH \u526f\u6a94\u540d\u3002<\/p>\n<p>\u6211\u5c07\u4e0d\u518d\u8a0e\u8ad6 shell \u8173\u672c\u7684\u57fa\u790e\u77e5\u8b58\u3002\u5982\u679c\u60a8\u60f3\u5b78\u7fd2\u5728 Mac \u4e0a\u5efa\u7acb shell \u8173\u672c\uff0c\u8acb\u67e5\u770b Apple<a href=\"https:\/\/developer.apple.com\/library\/archive\/documentation\/OpenSource\/Conceptual\/ShellScripting\/shell_scripts\/shell_scripts.html\" rel=\"noreferrer noopener\" target=\"_blank\">\u5b98\u65b9\u7684 Shell \u8173\u672c\u5165\u9580<\/a>\u3002\u4e5f\u5c31\u662f\u8aaa\uff0c\u70ba\u4e86\u907f\u514d\u982d\u75db\u548c\u5fc3\u75db\uff0c\u60a8\u9700\u8981\u8a18\u4f4f\u5169\u500b\u95dc\u65bc shell \u8173\u672c\u7684\u6cd5\u898f\uff1a<\/p>\n<p><strong>1.<\/strong> <strong>\u76f2\u76ee\u6388\u4e88\u6b0a\u9650\u53ef\u80fd\u6703\u9069\u5f97\u5176\u53cd<\/strong>\uff0d\u901a\u5e38\uff0cshell\u8173\u672c\u4e0d\u9700\u8981root\u4f7f\u7528\u8005\uff08\u7ba1\u7406\u54e1\u7b49\u7d1a\u6b0a\u9650\uff09\u4f86\u904b\u4f5c\u3002\u4f46\u662f\uff0c\u60a8\u53ef\u80fd\u5fc5\u9808\u63d0\u4f9b\u57f7\u884c shell \u8173\u672c\u7684\u6b0a\u9650\uff0c\u8a72\u8173\u672c\u9700\u8981 sudo \u4f7f\u7528\u8005\uff08\u7ba1\u7406\u54e1\uff09\u6b0a\u9650\u624d\u80fd\u57f7\u884c\u9078\u64c7\u7684\u547d\u4ee4\u3002\u4f46\u662f\uff0c\u6211\u5011\u5f37\u70c8\u5efa\u8b70\u60a8\u5728\u6388\u4e88\u5b8c\u5168\u6b0a\u9650\u4e4b\u524d\u4ed4\u7d30\u6aa2\u67e5 shell \u8173\u672c\u7684\u5167\u5bb9\u53ca\u5176\u4f86\u6e90\u3002<\/p>\n<p>\u4f5c\u70ba\u4e00\u9805\u5b89\u5168\u63aa\u65bd\uff0cmacOS \u4e0d\u6703\u63d0\u4f9b\u60a8\u57f7\u884c\u9700\u8981\u4fc2\u7d71\u8cc7\u6599\u593e root \u6b0a\u9650\u7684\u8173\u672c\u7684\u6b0a\u9650\u3002<\/p>\n<p><strong>2.<\/strong> <strong>\u6aa2\u67e5 shell \u8173\u672c\u7684\u5167\u5bb9<\/strong>\u2013 \u4f7f\u7528 Sublime Text \u7b49\u6587\u5b57\u7de8\u8f2f\u5668\u67e5\u770b\u5f9e\u5176\u4ed6\u5730\u65b9\u7372\u5f97\u7684 shell \u8173\u672c\u6216\u5efa\u7acb\u65b0\u8173\u672c\u3002\u7121\u8ad6\u60a8\u80fd\u5f9e\u4e2d\u770b\u51fa\u982d\u9084\u662f\u5c3e\uff0c\u6587\u5b57\u7de8\u8f2f\u5668\u90fd\u53ef\u4ee5\u986f\u793a\u60a8\u53ef\u4ee5\u8f15\u9b06\u5728\u7dda\u9a57\u8b49\u7684\u547d\u4ee4\u3002<\/p>\n<p><a href=\"https:\/\/www.sublimetext.com\/download_thanks?target=mac\" rel=\"noreferrer noopener\" target=\"_blank\"><strong>\u4e0b\u8f09 Mac \u7248 Sublime \u7de8\u8f2f\u5668<\/strong><\/a><\/p>\n<h2><span id=\"Try-This-Test-Script\">\u8a66\u8a66\u9019\u500b\u6e2c\u8a66\u8173\u672c<\/span><\/h2>\n<p>\u5728\u672c\u6307\u5357\u4e2d\uff0c\u6211\u4f7f\u7528\u4ee5\u4e0b\u7a0b\u5f0f\u78bc\u5728 Sublime Text \u7de8\u8f2f\u5668\u4e2d\u5efa\u7acb shell \u8173\u672c\uff1a<\/p>\n<p> <code> <code>#! \/bin\/bash<br \/>\necho \"Hello World!\"<\/code><\/code><\/p>\n<figure class=\"wp-block-image\"><img alt=\"\u5728 Sublime Text \u7de8\u8f2f\u5668\u4e2d\u6e2c\u8a66 shell \u8173\u672c\u6a94\u3002\" class=\"wp-image\" decoding=\"async\" height=\"723\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/04\/Test-Shell-Script-1024x723-1.webp\" title=\"\u5728 Sublime Text \u7de8\u8f2f\u5668\u4e2d\u6e2c\u8a66 shell \u8173\u672c\u6a94\u3002\" width=\"1024\"\/><\/figure>\n<p>\u4e4b\u5f8c\uff0c\u6211\u5c07\u6587\u4ef6\u5132\u5b58\u70ba test.sh \u4ee5\u9032\u884c\u6e2c\u8a66\u3002<\/p>\n<h2><span id=\"Easy-Way-to-Run-the-Shell-Script-on-Mac\">\u5728 Mac \u4e0a\u904b\u884c Shell \u8173\u672c\u7684\u7c21\u55ae\u65b9\u6cd5<\/span><\/h2>\n<p>\u904b\u884c shell \u8173\u672c\u7684\u6700\u7c21\u55ae\u65b9\u6cd5\u662f\u5728\u7d42\u7aef\u6a5f\u4e2d\u6253\u958b\u5b83\u4e26\u89c0\u5bdf\u5b83\u7684\u904b\u884c\u3002\u4f46\u662f\uff0c\u5982\u679c\u60a8\u4e0d\u77e5\u9053 shell \u8173\u672c\u53ef\u80fd\u57f7\u884c\u7684\u64cd\u4f5c\u53ca\u5176\u8d77\u6e90\uff0c\u90a3\u9ebc\u9019\u662f\u4e00\u500b\u5192\u96aa\u7684\u8209\u52d5\u3002\u7d42\u7aef\u5c07\u9810\u8a2d\u904b\u884c\u6211\u5011\u7684\u6e2c\u8a66\u8173\u672c\uff0c\u56e0\u70ba\u5b83\u6c92\u6709\u9700\u8981 root \u4f7f\u7528\u8005\u6b0a\u9650\u7684\u547d\u4ee4\u3002<\/p>\n<p><strong>1.<\/strong>\u4f7f\u7528 Spotlight \u641c\u5c0b\u6216 Mac \u4e0a Finder \u4e2d\u7684\u61c9\u7528\u7a0b\u5f0f\u8cc7\u6599\u593e\u958b\u555f<strong>\u7d42\u7aef\u61c9\u7528\u7a0b\u5f0f<\/strong>\u3002\u5728\u7d42\u7aef\u6a5f\u8996\u7a97\u4e2d\uff0c\u5207\u63db\u5230 shell \u8173\u672c\u6240\u5728\u7684\u8cc7\u6599\u593e\u3002<\/p>\n<figure class=\"wp-block-image\"><img alt=\"\u5728 Mac \u4e0a\u7684\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u66f4\u6539\u5305\u542b shell \u8173\u672c\u7684\u76ee\u9304\" class=\"wp-image\" decoding=\"async\" height=\"606\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/04\/Change-Directory-to-Shell-Script-Location-1024x606-1.webp\" title=\"\u5728 Mac \u4e0a\u7684\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u66f4\u6539\u5305\u542b shell \u8173\u672c\u7684\u76ee\u9304\" width=\"1024\"\/><\/figure>\n<p><strong>2.<\/strong>\u5728\u7d42\u7aef\u6a5f\u8996\u7a97\u4e2d\uff0c\u9375\u5165\u4ee5\u4e0b\u547d\u4ee4\u4e26\u6309\u4e0b<strong>\u56de\u8eca<\/strong>\u9375\uff1a<\/p>\n<p> <code> <code>sh &lt;shell script file name&gt;<\/code><\/code><\/p>\n<figure class=\"wp-block-image\"><img alt=\"\u5728 Mac \u4e0a\u7684\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u6e2c\u8a66 shell \u8173\u672c\u6587\u4ef6\" class=\"wp-image\" decoding=\"async\" height=\"605\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/04\/Shell-Script-file-Run-1024x605-1.webp\" title=\"\u5728 Mac \u4e0a\u7684\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u6e2c\u8a66 shell \u8173\u672c\u6587\u4ef6\" width=\"1024\"\/><\/figure>\n<p>\u6216\u8005\uff0c\u60a8\u53ef\u4ee5\u5728\u96a8\u5f8c\u7684\u7d42\u7aef\u6a5f\u8996\u7a97\u4e2d\u9375\u5165 sh\u3002\u7136\u5f8c\uff0c\u5c07 shell \u8173\u672c\u5f9e Finder \u8996\u7a97\u62d6\u653e\u5230\u958b\u555f\u7684\u7d42\u7aef\u6a5f\u7a97\u53e3\uff0c\u7136\u5f8c\u6309 Return \u9375\u3002<\/p>\n<p><strong>3.<\/strong> shell \u8173\u672c\u7684\u8f38\u51fa\u5c07\u51fa\u73fe\u5728\u7d42\u7aef\u6a5f\u8996\u7a97\u4e2d\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u4f7f\u7528 test.sh \u6587\u4ef6\uff0c\u60a8\u5c07\u770b\u5230 Hello World\uff01\u5728\u8996\u7a97\u4e2d\u3002<\/p>\n<figure class=\"wp-block-image\"><img alt=\"\u5728 Mac \u4e0a\u7684\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u6210\u529f\u57f7\u884c shell \u8173\u672c\" class=\"wp-image\" decoding=\"async\" height=\"606\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/04\/Shell-Script-Run-Success-1024x606-1.webp\" title=\"\u5728 Mac \u4e0a\u7684\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u6210\u529f\u57f7\u884c shell \u8173\u672c\" width=\"1024\"\/><\/figure>\n<p>\u5982\u679c\u8a72\u6a94\u6848\u6c92\u6709\u57f7\u884c\uff0c\u90a3\u9ebc\u60a8\u9700\u8981\u70ba shell \u8173\u672c\u6a94\u6848\u6388\u4e88\u9069\u7576\u7684\u57f7\u884c\u6b0a\u9650\uff1a<\/p>\n<p> <code> <code>sudo chmod +x &lt;shell script file location&gt;<\/code><\/code><\/p>\n<figure class=\"wp-block-image\"><img alt=\"\u5728 Mac \u4e0a\u7684\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u70ba shell \u8173\u672c\u6a94\u6848\u6388\u4e88\u5fc5\u8981\u7684\u6b0a\u9650\" class=\"wp-image\" decoding=\"async\" height=\"606\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/04\/Shell-Script-Permissions-in-macOS-1024x606-1.webp\" title=\"\u5728 Mac \u4e0a\u7684\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u70ba shell \u8173\u672c\u6a94\u6848\u6388\u4e88\u5fc5\u8981\u7684\u6b0a\u9650\" width=\"1024\"\/><\/figure>\n<p>\u6309\u4e0b\u56de\u8eca\u9375\u5f8c\uff0c\u60a8\u9700\u8981\u8f38\u5165\u7ba1\u7406\u54e1\u5e33\u865f\u5bc6\u78bc\u3002<\/p>\n<h2><span id=\"Safe-Way-to-Run-a-Shell-Script-on-Mac\">\u5728 Mac \u4e0a\u57f7\u884c Shell \u8173\u672c\u7684\u5b89\u5168\u6027\u65b9\u6cd5<\/span><\/h2>\n<p>\u6700\u597d\u5728\u7a0b\u5f0f\u78bc\u6587\u5b57\u7de8\u8f2f\u5668\uff08\u4f8b\u5982 Sublime Text\uff09\u4e2d\u6e2c\u8a66 shell \u8173\u672c\uff0c\u4ee5\u6aa2\u67e5\u8173\u672c\u7684\u53ef\u884c\u6027\u3002\u6b64\u5916\uff0c\u5728\u6587\u5b57\u7de8\u8f2f\u5668\u4e2d\u904b\u884c\u5b83\u662f\u5b89\u5168\u7684\uff0c\u56e0\u70ba\u5b83\u4e0d\u6703\u66f4\u6539\u60a8\u7684\u7cfb\u7d71\u3002<\/p>\n<p><strong>1.<\/strong>\u5728 Mac \u4e0a\u555f\u52d5 Sublime Text \u6216\u4efb\u4f55\u5176\u4ed6\u6587\u5b57\u7de8\u8f2f\u5668\u4f86\u7de8\u5beb\u7a0b\u5f0f\u78bc\u3002\u5728\u5176\u4e2d\u958b\u555f\u60a8\u7684 shell \u8173\u672c\uff08\u672c\u6307\u5357\u4e2d\u70ba test.sh\uff09\u3002<\/p>\n<figure class=\"wp-block-image\"><img alt=\"Mac \u4e0a\u7684 Sublime Text Editor \u4e2d\u7684 Shell \u8173\u672c\u6587\u4ef6\" class=\"wp-image\" decoding=\"async\" height=\"780\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/04\/Shell-Script-in-Sublime-text-1024x780-1.webp\" title=\"Mac \u4e0a\u7684 Sublime Text Editor \u4e2d\u7684 Shell \u8173\u672c\u6587\u4ef6\" width=\"1024\"\/><\/figure>\n<p><strong>3.<\/strong> <span data-preserver-spaces=\"true\">\u60a8\u9700\u8981\u4f7f\u7528\u7d42\u7aef\u6a5f\u6388\u4e88 shell \u8173\u672c\u57f7\u884c\u6b0a\u9650\u3002<\/span><\/p>\n<figure class=\"wp-block-image\"><img alt=\"\" class=\"wp-image\" decoding=\"async\" height=\"606\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/04\/Shell-Script-Permissions-in-macOS-1-1024x606-1.webp\" title=\"\" width=\"1024\"\/><\/figure>\n<p><strong>4.<\/strong>\u8fd4\u56deSublime Text\u7a97\u53e3\uff0c\u9ede\u64ca\u9802\u90e8\u9078\u55ae\u5217\u4e0a\u7684\u300c\u5de5\u5177\u300d\u9078\u9805\uff0c\u7136\u5f8c\u5f9e\u4e0a\u4e0b\u6587\u9078\u55ae\u4e2d\u9078\u64c7\u300c\u5efa\u7f6e\u300d\u3002<\/p>\n<figure class=\"wp-block-image\"><img alt=\"\" class=\"wp-image\" decoding=\"async\" height=\"816\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/04\/Build-in-Sublime-text-1024x816-1.webp\" title=\"\" width=\"1024\"\/><\/figure>\n<p><strong>5.<\/strong> <span data-preserver-spaces=\"true\">\u8b93\u8173\u672c\u5728 Sublime text \u5167\u7684\u8996\u7a97\u4e2d\u904b\u4f5c\u3002\u60a8\u5c07\u6536\u5230\u6709\u95dc\u5176\u5b8c\u6210\u7684\u8a0a\u606f\u3002<\/span><\/p>\n<figure class=\"wp-block-image\"><img alt=\"\" class=\"wp-image\" decoding=\"async\" height=\"780\" loading=\"lazy\" src=\"https:\/\/cdn.howtogeek.blog\/wp-content\/uploads\/2024\/04\/Shell-Script-Sublime-Text-Run-1024x780-1.webp\" title=\"\" width=\"1024\"\/><\/figure>\n<p>\u5982\u679c\u51fa\u73fe\u6b0a\u9650\u932f\u8aa4\uff0c\u8acb\u78ba\u4fdd\u518d\u6b21\u4f9d\u7167\u6b65\u9a5f 3 \u70ba shell \u8173\u672c\u6307\u6d3e\u9069\u7576\u7684\u6b0a\u9650\u3002<\/p>\n<h2><span id=\"Enjoy-Shell-Scripts-With-a-Little-Caution\">\u4eab\u53d7 Shell \u8173\u672c\u6642\u8981\u5c0f\u5fc3\u4e00\u9ede<\/span><\/h2>\n<p>\u5927\u591a\u6578\u7528\u65bc\u5b89\u88dd\u8edf\u9ad4\u6216\u5176\u4ed6\u8a08\u7b97\u4efb\u52d9\u7684 shell \u8173\u672c\u90fd\u7d93\u904e\u5176\u5275\u5efa\u8005\u7684\u6e2c\u8a66\u3002\u4f46\u5982\u679c\u4f60\u4e0d\u77e5\u9053\u5b83\u7684\u5f71\u97ff\u548c\u771f\u5be6\u6027\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528Mac\u4e0a\u7684\u6587\u5b57\u7de8\u8f2f\u5668\u4f86\u6aa2\u67e5\u8173\u672c\u53ef\u4ee5\u505a\u4ec0\u9ebc\u3002\u9019\u662f\u4e00\u7a2e\u66f4\u5b89\u5168\u7684\u6e2c\u8a66 shell \u8173\u672c\u7684\u65b9\u6cd5\uff0c\u800c\u4e0d\u662f\u8b93\u60a8\u7684 Mac \u9762\u81e8\u98a8\u96aa\u3002\u9664\u6b64\u4e4b\u5916\uff0c\u7d42\u7aef\u6a5f\u662f\u5728 Mac \u4e0a\u6e2c\u8a66\u548c\u57f7\u884c shell \u8173\u672c\u7684\u7d55\u4f73\u5de5\u5177\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Mac \u4e0a\u5b89\u88dd\u61c9\u7528\u7a0b\u5f0f\u76f8\u5c0d\u5bb9\u6613\uff0c\u5f88\u5c11\u9700\u8981\u91cd\u65b0\u555f\u52d5\u3002\u5927\u591a\u6578\u4eba\u5c07\u61c9\u7528\u7a0b\u5f0f\u5716\u793a\u62d6\u653e\u5230\u300c\u61c9\u7528\u7a0b\u5f0f\u300d\u8cc7\u6599\u593e\u4e2d\uff0c\u4f46\u66f8\u5446\u5b50\u4f7f\u7528 shell \u8173\u672c\u3002\u60a8\u4e5f\u53ef\u4ee5\u5728 Mac \u4e0a\u7684\u7d42\u7aef\u200b\u200b\u6a5f\u4e2d\u8f15\u9b06\u57f7\u884c shell \u8173\u672c\uff0c\u524d\u63d0\u662f\u60a8\u8981\u7262\u8a18\u4e00\u4e9b\u6ce8\u610f\u4e8b\u9805\u3002\u5c0d\u65bc\u521d\u5b78\u8005\u4f86\u8aaa\uff0c\u907f\u514d\u904b\u884c\u60a8\u5728\u7dda\u4e0b\u8f09\u7684\u8173\u672c\u800c\u4e0d\u77e5\u9053\u5b83\u53ef\u4ee5\u505a\u4ec0\u9ebc\u3002\u56e0\u6b64\uff0c\u5728 Mac \u4e0a\u904b\u884c shell \u8173\u672c\u6709\u5169\u7a2e\u65b9\u6cd5\u2014\u2014\u7c21\u55ae\u65b9\u6cd5\u548c\u5b89\u5168\u65b9\u6cd5\u3002 \u95dc\u65bc Shell \u8173\u672c\u60a8\u9700\u8981\u4e86\u89e3\u7684\u4e8b\u60c5 shell \u662f\u4e00\u7a2e\u57fa\u65bc\u6587\u5b57\u7684\u4e92\u52d5\u5f0f\u4ecb\u9762\uff0c\u53ef\u8207\u547d\u4ee4\u4e00\u8d77\u4f7f\u7528\u3002\u56e0\u6b64\uff0cshell \u8173\u672c\u5c31\u50cf\u4e00\u500b\u5305\u542b\u591a\u500b\u547d\u4ee4\u7684\u6587\u5b57\u6587\u4ef6\uff0c\u53ef\u5e6b\u52a9\u60a8\u907f\u514d\u70ba\u91cd\u8907\u4efb\u52d9\u91cd\u65b0\u8f38\u5165\u5b83\u5011\u3002\u9019\u6a23\u60a8\u5c31\u53ef\u4ee5\u5c07\u591a\u500b\u4efb\u52d9\u5408\u4f75\u5230\u4e00\u500b\u8173\u672c\u4e2d\uff0c\u4ee5\u7bc0\u7701\u6642\u9593\u4e26\u907f\u514d\u91cd\u8907\u4efb\u52d9\u6240\u9020\u6210\u7684\u932f\u8aa4\u3002 shell\u8173\u672c\u651c\u5e36\u7684\u6a94\u6848\u540d\u7a31\u3002 SH \u526f\u6a94\u540d\u3002 \u6211\u5c07\u4e0d\u518d\u8a0e\u8ad6 shell \u8173\u672c\u7684\u57fa\u790e\u77e5\u8b58\u3002\u5982\u679c\u60a8\u60f3\u5b78\u7fd2\u5728 Mac \u4e0a\u5efa\u7acb shell \u8173\u672c\uff0c\u8acb\u67e5\u770b Apple\u5b98\u65b9\u7684 Shell \u8173\u672c\u5165\u9580\u3002\u4e5f\u5c31\u662f\u8aaa\uff0c\u70ba\u4e86\u907f\u514d\u982d\u75db\u548c\u5fc3\u75db\uff0c\u60a8\u9700\u8981\u8a18\u4f4f\u5169\u500b\u95dc\u65bc shell \u8173\u672c\u7684\u6cd5\u898f\uff1a 1. \u76f2\u76ee\u6388\u4e88\u6b0a\u9650\u53ef\u80fd\u6703\u9069\u5f97\u5176\u53cd\uff0d\u901a\u5e38\uff0cshell\u8173\u672c\u4e0d\u9700\u8981root\u4f7f\u7528\u8005\uff08\u7ba1\u7406\u54e1\u7b49\u7d1a\u6b0a\u9650\uff09\u4f86\u904b\u4f5c\u3002\u4f46\u662f\uff0c\u60a8\u53ef\u80fd\u5fc5\u9808\u63d0\u4f9b\u57f7\u884c shell \u8173\u672c\u7684\u6b0a\u9650\uff0c\u8a72\u8173\u672c\u9700\u8981 sudo \u4f7f\u7528\u8005\uff08\u7ba1\u7406\u54e1\uff09\u6b0a\u9650\u624d\u80fd\u57f7\u884c\u9078\u64c7\u7684\u547d\u4ee4\u3002\u4f46\u662f\uff0c\u6211\u5011\u5f37\u70c8\u5efa\u8b70\u60a8\u5728\u6388\u4e88\u5b8c\u5168\u6b0a\u9650\u4e4b\u524d\u4ed4\u7d30\u6aa2\u67e5 shell \u8173\u672c\u7684\u5167\u5bb9\u53ca\u5176\u4f86\u6e90\u3002 \u4f5c\u70ba\u4e00\u9805\u5b89\u5168\u63aa\u65bd\uff0cmacOS \u4e0d\u6703\u63d0\u4f9b\u60a8\u57f7\u884c\u9700\u8981\u4fc2\u7d71\u8cc7\u6599\u593e root \u6b0a\u9650\u7684\u8173\u672c\u7684\u6b0a\u9650\u3002 2. \u6aa2\u67e5 shell \u8173\u672c\u7684\u5167\u5bb9\u2013 \u4f7f\u7528 Sublime Text \u7b49\u6587\u5b57\u7de8\u8f2f\u5668\u67e5\u770b\u5f9e\u5176\u4ed6\u5730\u65b9\u7372\u5f97\u7684 shell [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[18,204,205],"class_list":["post-1718","post","type-post","status-publish","format-standard","hentry","category-how-to","tag-macos","tag-programming","tag-shell-script"],"acf":[],"_links":{"self":[{"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/posts\/1718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/comments?post=1718"}],"version-history":[{"count":1,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/posts\/1718\/revisions"}],"predecessor-version":[{"id":1719,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/posts\/1718\/revisions\/1719"}],"wp:attachment":[{"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/media?parent=1718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/categories?post=1718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/howtogeek.blog\/zh\/wp-json\/wp\/v2\/tags?post=1718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}