Understanding sh vs bash
If you have worked with shell script before, you might be wondering why we used #!/bin/bash as our shebang in all our examples, and not #!/bin/sh. Many users think that the /bin/sh and /bin/bash programs work the same way as shell script interpreters on every system. This is not true – there are important differences between the two.
The most important difference is that /bin/sh may not even be the same program as /bin/bash, and may therefore lack many of the programming features Bash adds that are not specified by the POSIX standard. Some GNU/Linux systems use bash as their /bin/sh implementation (Arch Linux, CentOS), but others do not (Debian GNU/Linux, Ubuntu).
When Bash is called as sh, it changes its behavior ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access