different way of executing shell script
what is the difference between including poundbang in the shell script or not using poundbang in the script?
count.ksh #!/bin/bash echo "hello" > ./count.ksh other way count.sh echo "hello" >sh count.sh |
Ok, first lets clarify that its not called a poundbang but a "shebang".
This declares the location of the interpreter for the language. Yes a simple echo can be run without one as if there is not one it will assume that /bin/sh should be used which is a sym link to whatever shell you are currently using(ksh, bash, etc..). The importance of this becomes clear as you try to create more indepth scripts in other languages. Here's how to see this in action: Put the following into a file and make it executable. Code:
print "I will now count my chickens:" Code:
#!/usr/bin/python NOTE: The above code was an excerpt take from http://learnpythonthehardway.org/book/ex3.html for use as a quick educational example. |
|
Indeed your 1st example calls it count.ksh, but it will run using bash because bash was specified; not a good idea...
If no shell is specified ie no shebang line, it'll use the current default shell, which may not be what you wanted. There are important differences between the various shell parsers. For prod code ALWAYS specify the one you want as the first line. |
All times are GMT -5. The time now is 10:54 AM. |