How does the #! work?

Posted by mocybin on Stack Overflow See other posts from Stack Overflow or by mocybin
Published on 2010-06-09T19:27:30Z Indexed on 2010/06/09 19:32 UTC
Read the original article Hit count: 108

Filed under:
|
|
|
|

In a script you must include a #! on the first line followed by the path to the program that will execute the script (e.g.: sh, perl). As far as I know though, the # character denotes the start of a comment and that line is supposed to be ignored by the program executing the script. It would seem though, that this first line is at some point read by something in order for the script to be executed by the proper program. Could somebody please shed more light on the workings of the #! ?

Edit: I'm really curious about this, so the more in-depth the answer the better.

© Stack Overflow or respective owner

Related posts about perl

Related posts about unix