-
Step 1
Create and open a new file with your text editor of choice and name it test_script.sh.
-
Step 2
Create the shebang line. This is the beginning of any Unix script and sets what interpreter will be used for the script. A shebang line looks like this:
#! /bin/sh
Type this is in as the first line. The line of text following #! is the path to the interpreter to be used. In this case it is the Bourne shell, which is found on all Unix systems. -
Step 3
Add commands to the script. Commands and programming logic are added after the shebang line. In this script we'll write a message to the terminal. Type this into your script:
echo "Hello test script!" -
Step 4
Save the changes you've made to the file. Before closing it, make sure you have included the shebang line and that the path to the interpreter is correct for your system.
-
Step 5
Make the script executable. Move to the command line if you aren't already at it. Navigate to the directory you created the script in and enter the following to make your script executable:
chmod 755 test_script.sh -
Step 6
Run the script from the command line by typing this:
./test_script.sh
You should see the text "Hello test script!" printed out to the command line.








