Thursday, December 16, 2010

Shell scripting for Mac (using bash)

An easy example using vi:


1. Type 'vi myscript' into the terminal.

2. Press 'i' for insert, and type your file. For example:

#!/bin/bash
echo "This is my script. Woo"

3. Press 'esc' key to exit insert mode.

4. Press shift+ZZ to save the file and exit.

5. Change the access rights on your file so it can be executed. For example:

chmod -x myscript

6. Execute your script by typing:

./myscript


That should get you started :)

No comments:

Post a Comment