Shebang (Unix)

Shebang (Unix)

In computing, a shebang (also called a sha-bang, hashbang, pound-bang, hash-exclam, or hash-pling), when it occurs as the initial two characters on the initial line of a script, is the character sequence consisting of the characters number sign and exclamation mark (that is, "#!").

Under Unix-like operating systems, when a script with a shebang is run as a program, the program loader parses the rest of the script's initial line as an interpreter directive; the specified interpreter program is run instead, passing to it as an argument the path that was initially used when attempting to run the script. For example, if a script is named with the path "path/to/script", and it starts with the following line:

#!/bin/sh

then the program loader is instructed to run the program "/bin/sh" instead (usually this is the Bourne shell or a compatible shell), passing "path/to/script" as the first argument.

The shebang line is usually ignored by the interpreter because the "#" character is a comment marker in many scripting languages; some language interpreters that do not use the hash mark to begin comments (such as Scheme) still may ignore the shebang line in recognition of its purpose.

Read more about Shebang (Unix):  Syntax, Examples, Purpose, Portability, Etymology, History, See Also