Quote:
Originally Posted by sons_of_bitch
why some of the scrip file is without the starting #!/bin/bash or any shell, and can straight away coding? what is the different between with starting #!/bin/bash or without the #!/bin/xxx in the starting script?
sorry i'm new in unix..
Thanks
|
If you are writing a script that you know, with 100% certainty, will always be run on a machine where the only available shell is the one you're using to write the script - then this line is completely optional.
If, however, there exists a possibility that some user will use a different shell - then you MUST specify the shell to be used for your script.
For example - if you use a script command that only exists in the /bin/csh shell - and your user happens to be using the /bin/sh shell - it is very likely that your script will fail.
(I almost would guarantee failure in this instance...)
But, if you force your script to run in a specific shell using the
!shebang then your script will function correctly.