The #! Syntax used in scripts to indicate an interpreter for execution under UNIX/Linux operating systems. Most Linux shell and Perl/Python script starts with the following line.
#!/bin/bash
OR
#!/usr/bin/perl
OR
#!/usr/bin/python
- It is called a shebang or a “bang” line.
- It is nothing but the absolute path to the Bash interpreter.
- It consists of a number sign and an exclamation point character (#!), followed by the full path to the interpreter such as /bin/bash.
- All scripts under Linux execute using the interpreter specified on a first line.
- Almost all bash scripts often begin with #!/bin/bash (assuming that Bash has been installed in /bin)
- This ensures that Bash will be used to interpret the script, even if it is executed under another shell.
- The shebang was introduced by Dennis Ritchie Version 7 Unix and 8 at Bell Laboratories.
- If you do not specify an interpreter line, the default is usually the /bin/sh. But, it is recommended that you set #!/bin/bash line.