Th batch launcher or shebang is the first line of a script file that describe the interpreter to use (bash, ksh, awk, etc.).
Example:
#!/bin/bash
/bin/bash\r
with unexpected ending characters will not be found on the system and the script will not be executed.
0xEF 0xBB 0xBF!/bin/bash
will not be executed because of 3 BOM characters (UTF-8 hexadecimal example).
Example of error obtained in the case of a Windows format script file:
-bash: ./windows-format-launcher.sh : /bin/bash^M : bad interpreter: No such file or directory
The classic method:
#!/bin/bash
#!/bin/bash -i
#!/bin/bash -ix
Shebang examples:
#!/bin/bash
#!/usr/bin/bash
#!/usr/bin/ksh
#!/bin/sh
#!/bin/awk -f
The intrepreter to use is passed as argument of the env
command and will be search in directores defined on the PATH environement variable.
#!/usr/bin/env bash
env
command path must be absolute!
Shebang examples:
#!/bin/env bash
#!/usr/bin/env ksh93
#!/usr/bin/env sh
Some very usefull shebang:
#!/bin/sh
#!/bin/bash
#!/bin/ksh
#!/bin/awk -f
#!/bin/sed -f
#!/usr/bin/nodejs
nodejs
can be installed as node
on some Linux distribution.