Friday, May 2, 2014

bash vs sh

There is always a confusion as to why we define the following while writing a shell script in unix based system:
#! /bin/sh (or) #! /bin/bash
#! is known as shebang which lets the rest of the line to be considered as a interpreter directive by the program loader. Thus the program loader knows which interpreter needs to be used to execute the shell script.
sh - Bourne Shell used to be the default shell of the old unix systems.
bash - Bourne-again shell is the outcome of the GNU project and it supersedes sh. In Mac and most of the linux distributions bash is shipped as the default interpreter. In fact sh is considered as a system shell and hence in most distributions is mostly a symbolic link to bash.

No comments:

Post a Comment