0 votes
in Programming by (1.9k points)
what does #!/bin/bash at the 1st line mean ? Is it just a comment and ignored by the shell like all other comments in program

OR

Only this line is interpreted by the interpreter and all the other lines starting from # are ignored except #!/bin/bash.

1 Answer

0 votes
by (2k points)

The first Line tells the computer which interpreter to use while executing the file

Let's say you write a script using python, and while running this script you will use the python interpreter and how would computer know which interpreter to use, it will know through this line which is also called the Shebang, for python

#!/usr/bin/env python
print "Hello world"

let's say again you write a script in bash and you use the shebang for bash script which tell the computer to use the bash interpreter while executing this code

 #!/usr/bin/bash 
  echo "Hello world" 

 

I think it fulfill your need!

...