如何使Shell脚本成为全局脚本? [英] How to make a shell script global?
问题描述
我在Mac OS 10.6上,并且我试图学习一两个有关Shell脚本的知识.我知道如何保存shell脚本并使之可执行,但是我想知道我能做什么或者可以在哪里保存文件以使其成为全局文件(也就是说,无论我位于哪个文件夹中,都可以访问该文件).
I am on Mac's OS 10.6, and I am trying to learn a thing or two about shell scripting. I understand how to save a shell script and make it executable, but I am wondering what I can do or where I can save the file to make it global (that is, accessible no matter what folder I am in).
例如,如果我将.sh文件保存在/Users/username/目录中并使其可执行,则只能在该特定目录中执行该脚本.例如,如果我导航到/Users/username/Downloads,则无法执行脚本.
For example, if I save a .sh file in the /Users/username/ directory and make it executable, I can only execute that script in that specific directory. If I navigate to /Users/username/Downloads, for example, I can't execute the script.
此外,任何有关进一步了解Shell脚本的资源建议都将有所帮助.谢谢
Also, any suggestions of resources for learning more about shell scripting would be helpful. Thanks
推荐答案
/usr/local/bin
将是最合适的位置. Mac OS X默认将其放在PATH
/usr/local/bin
would be the most appropriate location. Mac OS X has it in the PATH
by default
这篇关于如何使Shell脚本成为全局脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!