shebang
shebang is the character sequence #!
used at the start of a script to indicate the values that follows will be an interpreter directive. This essentially controls which interpreter parses and interprets the instructions in the particular computer program that follows.
Example
Given the following file named test
The contents of the
test
file is shown to contain a print statement in Python languageThe file executed with the
./test
commandAn error is thrown
This is because the shebang is not specified. Thus, the default interpreter value (
/bin/sh
) is used.
To specify to the shell to use the python interpreter (
/usr/bin/python3
), the shebang needs to be included at the top of the scriptWhen the script is ran again, the interpreter
/usr/bin/python3
is used.
Last updated