The difference between bash and sh

bashshellunix

I see two types of code being used:

#!/usr/bin/sh

and:

#!/user/bin/bash

I searched for this online and opinions vary a lot. The explanations I saw on most websites say that sh is older than bash, and that there is no real difference.

Does someone know the difference between these? Can you give me a practical example when to use one over the other?

Best Answer

bash is a superset of sh ie. everything you can do in sh you can do in bash.

Bash has more features (branching, builtins, arrays) making script easier to write. Some later *nix'es have /bin/sh as a link to /bin/bash

For a full explanation of what here's a tutorial