Shebang lines…

Shebang(also known as ‘hashbang’) refers to the characters #! when they are the first two characters (occurring at the left most corner, i.e the beginning of the very first line) of your script. The particular line that contains the shebang is the shebang line in your script.
Now what’s shebang meant to do.?
In a unix-like operating system , the program loader (part of the operating system thats responsible for loading programs) finds the presence of these two characters(#!) , identifies it as a script and tries to execute it with the interpreter that will be specified using the remaining lines of the script.
For example consider writing a shebang line for a python script..
First and foremost you need to find the location of the interpreter for that particular script…
$which python

Therefore…the shebang line should be set as…
#! /usr/bin/python
Specifying the shebang line would execute your script as follows:
./’script name’.py instead of doing ‘python ‘script name’.py’
You could try out the use of shebang lines for any of the following types of scripts
‘werbel’, ‘tinypy’ ,’perl’…..and many more…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s