First, meaning
#!/bin/sh means that this script uses /bin/sh to interpret execution,#! is a special designator, which is followed by the path to the shell that interprets this script.
In fact, the first sentence of #! is the script interpreter program path, the content of the script is interpreted by the interpreter, we can use a variety of interpreters to write the corresponding script.
such as /bin/csh scripts,/bin/perl scripts,/bin/awk scripts,/bin/sed scripts, even /bin/echo , and so on.
#!/bin/bash .
Second, the difference
/bin/sh in the Gnu/linux operating system is a symbolic link to Bash (bourne-again Shell) , but given that bash is too complex, someone puts bash Ported from NetBSD to Linux and renamed to Dash (Debian almquist Shell), it is recommended to point /bin/sh to it for faster script execution. The Dash shell is much smaller than the bash shell and is POSIX compliant.
Ubuntu inherits Debian, so the default is dash Shell starting with Ubuntu 6.10.
It should be said that although the/bin/sh and /bin/bash are largely indistinguishable, there are still different standards. Scripts marked as #!/bin/sh should not use any POSIX -defined features (such as Let commands, but #!/bin/bash can). Debian used /bin/bash to change the /bin/dashto use less disk space, provide less functionality, and get faster speeds. However, there was a running problem after the shell script test. Because of the shell script that was originally run under the bash Shell , there are some unexpected problems under /bin/sh , not 100%.
The above can be understood, using the man sh command and the man Bash command to observe, you can find that sh itself is Dash, It is also better to explain the changes after the integration of the Debian system.
Above reference: http://blog.chinaunix.net/uid-27037833-id-3431985.html
What does the Linux script start with #!/bin/bash and #!/bin/sh mean and the difference