What is Bash File Extension – .sh or nothing

Bash File Extension

Bash File Extension – In this Bash Tutorial, we shall learn about the extension provided to Bash Script File.

No extension is required for Bash Script File when you specify Hash Bang,  #!/bin/bash , as the first line of code. The Hash Bang is a Kernel convention and helps the Kernel in deciding the interpreter. OK, lets take it slow. The scripts can be in bash, python, perl, php, etc. And specifying the interpreter in Hash Bang is sufficient for your Kernel to execute the Script.


Following is an example program with no extension specified, but provided with Hash Bang.


.sh extension

If you do not specify Hash Bang, you may use .sh extension. An example is provided below :