On 20-Sep-98 Kuruvilla Chandy wrote:
> Hi,
>  
> Why do a lot of bash scripts start with the first line as #!/bin/bash?

That's not part of the bash script. The #!/bin/bash indicates that when the
script is ran, what is actually executed is "/bin/bash scriptfilename". If the
#!/bin/bash line is not present, the script is normally interpreted by the
current shell using a separate process. This generally wouldn't make a lot of
difference if the current shell is the same as that which the script requires,
but will fail if it is not.

Try it. Replace #!/bin/bash with the pathname to your favorite text editor (eg.
#!/usr/bin/joe). When executed, the specified editor will be executed with the
name of the script as it's argument. Try playing around with this feature, it
can be quite useful even with programs which are not normally used for
interpreting scripts.

Disclaimer:
Do note that I'm not particularly familiar with the how this feature is
implemented, and as such, may have made some mistakes in my explanation.
However, my explanation should be sufficient for most uses. In particular, I'm
not certain if this feature is implemented by the kernel or the shell.

Cort
[EMAIL PROTECTED]

Reply via email to