Shebang #! in Linux Scripts
1. Introduction
When you write scripts in Linux you have to know the meaning of the first line from a bash script and why you need it. In a non-computer science environment phrase “the whole shebang” means “everything”.
In computer science, a shebang is a sequence of characters. The first character is a number sign (#) and the second is an exclamation mark (!). This is also known as sharp-exclamation, sha-bang, hashbang, pund-bang, or hash ping.
2. Why do we use the shebang?
The first line from a file is an executable in the Unix operating system. The program loader parser will know that the first line will be interpreted as a directive. The loader will execute the specified interpreter program set in the first shebang line and as a first parameter will pass the path of the initial script. That program may use the file as input data. So basically the shebang line is a way to declare what interpreter the operating system will use to parse the script file.
E.g: We have a script test.sh and the first line is #!/bin/sh then the program loader will know to run the program /bin/sh and pass the test.sh as a first argument.
The syntax of the shebang is:
#!<path to interpreter> [optional-arg]
For more information about the shebang concept, you can check out Sign up

