It works like running a .bat file on Windows, but there are a couple of things to keep in mind:
The file has to be executable. Let’s say it’s called myscript.sh. Here’s how you’d make it executable:
chmod +x myscript.sh
Then, if you want to run it from the same directory that you’re in, you have to specify the current directory, like this:
Nice explanation from notjustjay in this macrumors forum thread.