The Shebang Line
In this page:
The Shebang Line
The first line of a script, #!/bin/bash, is the shebang — it tells the operating system which interpreter should run the file when executed directly. Without it, ./script.sh might use the wrong shell and behave unexpectedly. The shebang must be the very first line, with no blank line above it.
Note: #!/usr/bin/env bash is a more portable shebang that finds bash wherever it is on the PATH.
Example: The Shebang Line
#!/bin/bash
# This shebang tells the OS to run this file with bash
echo "Running under: $0"
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: