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).
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.
Also, any suggestions of resources for learning more about shell scripting would be helpful. Thanks
/usr/local/bin
would be the most appropriate location. Mac OS X has it in the PATH
by default
Traditionally, such scripts either go in ~/bin
(ie: the bin directory in your home directory) or /usr/local/bin/
The former means the script will only work for you, the latter is for scripts you want anybody on the system to be able to run.
If you put it in ~/bin
, you may need to add that to your PATH environment variable. /usr/local/bin
should already be on the path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With