In bash script, what does #!/bin/bash at the 1st line mean ?
UPDATE: Is there a difference between #!/bin/bash and #!/bin/sh ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That is called a shebang, it tells the shell what program to interpret the script with, when executed.
In your example, the script is to be interpreted and run by the bash shell.
Some other example shebangs are:
(From Wikipedia)
and a few additional ones I can think off the top of my head, such as:
In a script with the bash shebang, for example, you would write your code with bash syntax; whereas in a script with expect shebang, you would code it in expect syntax, and so on.
Response to updated portion:
It depends on what
/bin/shactually points to on your system. Often it is just a symlink to/bin/bash. Sometimes portable scripts are written with#!/bin/shjust to signify that it’s a shell script, but it uses whichever shell is referred to by/bin/shon that particular system (maybe it points to/bin/bash,/bin/kshor/bin/zsh)