Table of Contents
Script configuration
Declare the interpreter
In the first row of a script should be declared the interpreter to be used for its execution:
#!/bin/bash
When executing the script my_script.ext
, the file extension ext
doesn't tell the operating system which interpreter should be used.
Therefore, if two files my_script.py
and my_script.sh
have both the shebang #!/bin/bash
, then both will be executed using the bash interpreter.
If the shebang is not declared, the bash interpreter is used by default.
If the script does not have permission to be executed, the interpreter must be declared before the script: bash /path/my_script
.
Make the script executable
To be able to use the command ./my_script
, that is without specifying the interpreter, the script must have permission to be executed.
After the script is saved, change its permissions with the command:
chmod ugo=+x my_script