The files with the extension bash and sh

File names in POSIXland don't have "extensions". A . in a filename is no different from any other character and has no specific meaning other than those that might be attributed to them by meatbags such as ourselves.

One could hope that any file with a name ending in .bash would be a script meant to be executed via the bash shell, but there is no guarantee of this.

Indeed, it's quite common to give all shell scripts a suffix of .sh no matter which interpreter is intended for their use, as the shebang line should properly specify which shell should be used to execute such a file.

sh and bash are two different, but related, shells; two amongst many others such as ksh, csh, zsh, fish, ash, dash, and yet more others.

Each shell has its own syntax, capabilities, mannerisms, and foibles; some shells are largely compatible with each other (generally any script written for sh can also be run in bash or many other shells), but some are not.


The only significant issue I find day-to-day between bash and sh is the comparison operator. In bash the double-equals operator == can be used for string comparison:

if [ "$var" == "foo" ]; then  # bash

But in sh this is a syntax error, as it expects single-equals.

if [ "$var" = "foo" ]; then   # sh

I am not saying this is the only difference, but this is a commonly found issue.