In computing shebang is characters consist of number sign and exclamation mark
#!</strong>. There are alternative names like she-bang, hash-bang, pound-bang or hash-piling. Shebang is generally used in script-like text to specify script interpreter or type. Some languages omit # as comment mark but with
! there is special meaning.
Shebang is generally used with interpreter specification only and no optional argument is provided.
#!interpreter [optional argumen]
Here interpreter is the application used to interpret the following script. Most popular interpreters are Shell, Bash, Python, Perl, Php, etc.
#!/bin/bash echo "poftut.com"
Bash is the interpreter of the script. echo “poftut.com” will be interpreted as a bash script and will print “poftut.com” to the default output.
As we see in syntax section parameters can be provided to the specified interpreter. For example, it can be provided -x to enable debug in bash scripts like below.
#!/bin/bash -X echo "poftut.com"
Some operating system families process shebang differently. To make things more portable env technique can be used. This is useful if the specified interpreter path is different in different operating systems. Directly the path defined in the environment variable will be called.
#!/usr/bin/env bash echo "poftut.com"