Quote:
Originally Posted by
ourned
well Corona i understood your point but it is not exactly as you said "courtesy"
for example if i run the code with out including #!/bin/sh it also work so why to include it?
Without the #!, the OS will assume the default, /bin/sh.
But a UNIX system may have
many languages available. If a script needs /bin/bash, /bin/ksh, /bin/csh, /bin/zsh, /usr/bin/perl, /usr/bin/awk, or anything else, it can put it after #! and run the script using that instead.
It's traditional to put
#!/bin/sh up top even for scripts which don't need it. This is safer -- it's not impossible that a programmer might write a comment with #!, which would mess up the script if it didn't have #!/bin/sh first. If there's weird characters at the end of the line, having a #! will cause it to quit with 'bad interpreter' (since it can't find the filename /bin/sh^M) instead of trying to run invalid code inside a valid shell. It also lets a human instantly tell scripts apart from plain text files.