In computer programming, shebang refers to the hash/number sign (#) followed by an exclamation point (!) that begins most scripts, ie., #! . It is also sometimes called sha-bang or hashbang.

In Linux and other Unix-like systems, when a script with a shebang as the first line is run, the program loader takes the rest of the shebang line to be the path to the interpreter program for the script. This interpreter is launched and passed the path of the original script which it then runs. Because most interpreted languages use a hash sign to denote the beginning of a comment, the interpreter ignores the shebang line and proceeds to run the rest of the script.

For example, a Python script may begin with a shebang line like:

This, however, suffers from portability issues since the location of the python executable may vary from system to system. A more robust shebang line for Python scripts is:


« Back to Glossary Index

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.