Tag Archives: touch

BASH Scripting – How To Create Executable Script

There are many ways to achieve this – but I find this to be the fastest way as it is all done through command line.

Creating The Script File

Open Terminal.app from /Applications/Utilities/Terminal.app

In the Terminal window that opens, we are going to create a directory called scripts on our desktop and then create a shell script file within that directory – use the following command:

//"mkdir" creates a directory on your desktop - no different than right clicking on desktop
mkdir /Users/yourusername/Desktop/scripts

//"touch" just creates an empty file with a name and extension you specify
touch /Users/yourusername/Desktop/scripts/kickstartscript.sh

We also need to make the script executable.

//chmod is used to set permissions - in this case, executable permissions
chmod +x /Users/yourusername/Desktop/scripts/kickstartscript.sh

You now have an executable file. You can use any text editor (may I suggest TextWranger – just do a google search for it) to open the file made in the scripts directory on your desktop. You may also use VIM or other command line text editor as well, but chances are if you are reading this – you would be better suited to start with a program based text editor like TextWrangler.

Once you have the file open – all you have to do is add


to the top of your file and you are ready to start scripting.

The line above just tells Terminal that it is a bash file with bash commands.

Thanks for reading!