The first step in learning shell scripting

In this article I will explain you what the sha-bang (also known as shebang) is and will create and exec the Hello World script.

Watch Free Movies

What is the sha-bang (shebang)?

The shebang is the “#!” at the head of your script. It tells the operating system that the file is a set of commands that can be interpreted with a certain program. Following the shebang is the path of the program that interprets the script.

Example of shebang lines:

#!/bin/sed -f
#!/bin/awk -f

If the shebang line is missing from your script, it will be interpreted by the default system shell (usually bash on Linux and csh on *BSD).

How to create your first script:

I will use vim to write this in the file:

$ vim
echo "Hello World!"

How to invoke the recently created script with source or bash:

Now that the script was created, let’s exec it:

$ source
OR: $ bash
Hello World!

You can also set rx permissions to your script and exec it as an executable file:

$ chmod +rx
$ chmod 555

And exec it:

$ ./
Hello World!

If you liked this , read the next shell scripting article.

Scroll to Top