Sample Header Ad - 728x90

Use .sh or .bash extension for Bash scripts?

52 votes
3 answers
67734 views
(See https://unix.stackexchange.com/q/182869/10043) If I want my scripts to use the Bash shell, does using the .bash extension actually invoke Bash or does it depend on system config or the first shebang line. If both were in effect but different, which would have precedence? I'm not sure whether to end my scripts with .sh to just indicate "shell script" and then have the first line select the Bash shell (e.g. #!/usr/bin/env bash) or whether to just end them with .bash (as well as the setting in the first line). I want Bash to be invoked.
Asked by Michael Durrant (43563 rep)
Feb 4, 2015, 01:37 PM
Last activity: Feb 10, 2025, 07:53 PM