first line in shell scripting
hi guys
I am a bit confused with the first line while writing a shell script , if someone can please explain me the meaning of the first line " #!/bin/bash " the confusion for me is the # at the beginning , in shell scripting # means a comment. but in this case it loads the shell which the script must use,instead of commenting the line how is this possible. where is this defined , any particular file. so if someone can throw some light on this |
Hello,
Some clarifications on the 'shebang' or also called 'hashbang': http://wiki.linuxquestions.org/wiki/Shebang http://en.wikipedia.org/wiki/Shebang_(Unix) and a lot more to be found at Google. Kind regards, Eric |
the way i understand it is it identifies the file as a bash script and in my experience with editors like nano and vi the commented lines are preceded with two #. it is in python i notice one # marks a comment.
|
Hi citi,
In Bash it also considers only 1 # as a comment, if you want to put two no problem but one suffices. The only difference with the 'shebang' is that it must be the first two characters in a file. If the first character is a # directly followed by ! then it gets interpreted as 'shebang' or 'hashbang' and the command following it will be used to process the file (bash, sh, perl, python, ...). Kind regards, Eric |
All times are GMT -5. The time now is 07:25 AM. |