It's a way of defining of which shell should be invoked during execution of the script. It's called the Shebang.
Example, a file having the following Shebang line:
#!/bin/sh
would invoke the Bourne (sh) shell. So for example, your piece of script:
## Setting a default route
#!/bin/sh
/sbin/route add SUBNET $5
would make /sbin/route add SUBNET $5
run in the Bourne shell interpreter. /sbin/route add SUBNET $5
is just a comment and doesn't do anything. However, the shebang should be on the first line, therefore that comment at the top will disallow the shebang to do its work, making it a useless addition.
There's a number of interpreters that are widely used and some typical interpreters for shebang lines are:
#!/bin/sh
— Execute using sh, the Bourne shell (or a compatible shell)
#!/bin/csh
— Execute using csh, the C shell (or a compatible shell)
#!/usr/bin/perl
— Execute using Perl
#!/usr/bin/python
— Execute using Python
#!/usr/bin/php
— Execute using PHP's command line interpreter
As Olli mentioned in his comments, sometimes env
(short for environment) is used to make sure the correct path to the interpreter is chosen.
1nice question! +1 – studiohack – 2011-02-23T14:30:30.750
possible duplicate of What exactly interpret #!/bin/bash line?
– Chris Johnsen – 2011-03-09T03:56:51.043