2008-02-15

BASH scripts on Mac OS X

I learned today how to use a BASH script on Mac OS X.

Just create a text file and put #!/bin/bash on the first line, and then write the rest of your BASH script and save.

Then make the file executable by opening Terminal and running
chmod +x scriptname.sh

Then you should be able to run it from the Terminal command line.

To make it so you can run the script by just double clicking on it in Finder, just change the extension of the script file to be .command

See Introduction to Open Source Scripting on Mac OS X