why we put #!/usr/bin/sh

Hi All,

why we put #!/usr/bin/sh in our 1rst line of shell script.
And can we place them after 4 lines which are not related to shell.

Pls provide me some insight on this.

Thanks inadvance

to tell in which shell, the script 'll be executed.

in ur case the script 'll be executed in sh shell.
#!/usr/bin/ksh - > for ksh shell.

etc

-anchal.

It's only necessary if you're not sure which shell the script will be running in.

But if you use it, it DOES have to be the first line.

Hi.

For more details, history, cautions, further references, etc. see Shebang (Unix) - Wikipedia, the free encyclopedia

Google and Wikipedia are your friends ... cheers, drl

Thanks. Lots of cool info there.

Of course, they are only your 'friends' if you know that #! is 'pronounced' "She-Bang".

Personally, I got a feeling that if you knew it's pronounced 'She-Bang', you'd already know it's purpose.

Hi.

If you search Wikipedia for the string #!/bin/sh or #!/usr/bin/sh the first hit is:

# Shebang (Unix)
... ne shell's behaviour, but be aware that using <tt>#!/bin/sh</tt> in [[shell script]]s may invoke different Bo ... #!/bin/sh
9 KB (1415 words) - 17:01, 21 March 2008

It is your friend ... cheers, drl