Here is the video version, if you prefer it:
The first part of a shell script is called a shebang. A shebang tells the kernel what interpreter to use to execute the script that follows. (Shotts, 2019) By interpreter, I mean the shell. (“Does the shebang determine the shell which runs the script?,” n.d.) You will recognize the shebang because it is the line that starts with #!
.
A sidenote: shell scripts are interpreted, not compiled.
Let’s now write a shebang in our script. Let’s name our script tutorialScript.sh
. In it, write the following as the first line:
#!/bin/bash
That tells the kernel to interpret our script using the bash interpreter. You have different-looking shebangs for different interpreters.
Hope you learned something useful!
References
Does the shebang determine the shell which runs the script? (n.d.). Retrieved February 21, 2020, from https://unix.stackexchange.com/questions/87560/does-the-shebang-determine-the-shell-which-runs-the-script
Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from http://linuxcommand.org/tlcl.php. Page 389