In the beginning of a file on my server (linux), which is located in the /etc/init.d/ folder I have this line:
!/bin/sh -e What does it mean, because every time I execute the rest of the script it works fine except for an error which shows:
!/bin/sh not found Any ideas?
42 Answers
That line defines what program will execute the given script. For sh normally that line should start with the # character as so:
#!/bin/sh -e The -e flag's long name is errexit, causing the script to immediately exit on the first error. A more detailed description from man sh:
1If not interactive, exit immediately if any untested command fails. The exit status of a command is considered to be explicitly tested if the command is used to control an
if,elif,while, oruntil; or if the command is the left hand operand of an&&or||operator.
#!/bin/bash this is the first line in the script to tell the system to use bash shell to execute the script.