Todays unix flavors come with more than a kind of shell you can run your program with. While executing a shell script, the kernel has to know which one of these needs to be used to execute your script. The first line pretty much says that.
Is used to tell the kernel that this script needs to be executed using the /bin/sh (standard shell)
You can run this command to list out all the different shells in your machine
Sharaths-MacBook-Air:~ sharath$ cat /etc/shells # List of acceptable shells for chpass(1). # Ftpd will not allow users to connect who are not using # one of these shells./bin/bash /bin/csh /bin/ksh /bin/sh /bin/tcsh /bin/zsh
The #! Is a general mechanism to invoke any programming language interpreter, not just the command shell.
#! /usr/bin/python a = 1+1 print a
The above script executes the script in python.