publish: true
wikipedia: https://en.wikipedia.org/wiki/Shebang_(Unix)
See wikipedia.
In computing, a shebang is the character sequence #!, consisting of the characters number sign (also known as sharp or hash) and exclamation mark (also known as bang), at the beginning of a script.
When a text file with a shebang is used as if it were an executable in a Unix-like operating system, the program loader mechanism parses the rest of the file's initial line as an interpreter directive. The loader executes the specified interpreter program, passing to it as an argument the path that was initially used when attempting to run the script, so that the program may use the file as input data.8(https://en.wikipedia.org/wiki/Shebang_(Unix)#cite_note-linux-8) For example, if a script is named with the path path/to/script, and it starts with the line #!/bin/sh
, then the program loader is instructed to run the program /bin/sh, passing path/to/script as the first argument.
The form of a shebang interpreter directive is as follows:
#!_interpreter_ [_optional-arg_]
in which interpreter is a path to an executable program. The space between #! and interpreter is optional. There could be any number of spaces or tabs either before or after interpreter. The optional-arg will include any extra spaces up to the end-of-line.
Some typical shebang lines:
#!/bin/sh
– Execute the file using the Bourne Shell, or a compatible shell, assumed to be in the /bin directory#!/bin/bash
– Execute the file using the Bash shell.
#!/usr/bin/pwsh
– Execute the file using PowerShell#!/usr/bin/env python3
– Execute with a Python interpreter, using the env program search path to find it#!/bin/false
– Do nothing, but return a non-zero exit status, indicating failure. Used to prevent stand-alone execution of a script file intended for execution in a specific context, such as by the **.**
command from sh/bash, source
from csh/tcsh, or as a .profile, .cshrc, or .login file.