Make a Unix/bash script executable in Mac OS X

For some reason I need make a script executable once every blue moon and I always seem to forget how to do it. Getting old is frustrating.

To make a script executable in Mac OS X, fire up Terminal.app and type this in at the prompt (or add a space after the “x” below and then drag your script on to the Terminal window):

chmod +x /file/path/script_name.sh

Press enter and you’re done. The single line above makes the script, named “script_name.sh” located in the directory “/file/path/”, executable. There are probably easier ways to do this, but it works for me.

To execute the script, just type the following into the terminal (assuming you’re in the same directory as the script):

./script_name.sh

Leave a Reply

Your email address will not be published. Required fields are marked *