Interview Prep/Linux/Packages, Shell & Text Tools

What does the shebang line do?

BeginnerConceptPackages, Shell & Text Tools
Answer

#!/path/to/interpreter on the first line tells the kernel which interpreter to run the script with. #!/usr/bin/env bash finds bash in $PATH, which is more portable than #!/bin/bash. A script with #!/bin/sh runs in dash on Debian/Ubuntu, so bashisms like [[ ]] or arrays fail. Windows line endings cause /bin/bash^M: bad interpreter.

All Linux questions Roadmap: Linux

More on Packages, Shell & Text Tools