Languages

Linux bash correct first line header

9 points
Asked by:
martineau
300

What is the correct first line when I create bash script?

1 answer
10 points
Answered by:
martineau
300

As I suppose that you are asking about first line of the script.

People uses bash and sh as substitutes but they are not the same.

Writing script it is necessary to set first line to indicates script interpreter.

#!/path/to/interpreter

Depending what interpreter you whould like to use we can select Bourne shell, Bash shell or something other (python, php, perl, lua, ...).

Using Bourne shell first line should be:

#!/bin/sh

Using Bash shell first line should be:

#!/bin/bash

Summary: bash is like improvement for sh.

Do not forget to add permissions to execute your script:

chmod u+x my_script.sh

See also:

  1. Bash correct header #!/bin/sh - create simple bin sh shell script with .sh code example

Resources

  1. https://en.wikipedia.org/wiki/Bash_(Unix_shell)
  2. https://en.wikipedia.org/wiki/Bourne_shell
0 comments Add comment
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

â€ïžđŸ’» 🙂

Join