Bash Script shebang Direct shebang

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

To execute a script file with the bash interpreter, the first line of a script file must indicate the absolute path to the bash executable to use:

#!/bin/bash

The bash path in the shebang is resolved and used only if a script is directly launch like this:

./script.sh

The script must have execution permission.

The shebang is ignored when a bash interpreter is explicitly indicated to execute a script:

bash script.sh


Got any Bash Question?