- There are two ways to run a shell script:
- As an executable program, if in a directory, write a shell script test.sh, you want to execute the script, the script will need to cd into the directory,
chmod + the X-./test. SH # script has execute permission . / the Test. SH # script execution
Attention must be written ./test.sh , rather than test.sh. Run Binary other programs, too, write directly test.sh, linux PATH system will go in search of anyone named test.sh, and only the / bin, / sbin, / usr / bin, / usr / sbin and so on in the PATH your current directory is usually not in the PATH, you will not find written test.sh command, use ./test.sh tell the system that you find in the current directory.
- As the interpreter parameters: directly run the interpreter, that argument is the shell script file name, such as
/bin/sh test.sh /bin/php test.php
- shell variables:
Note: no space between the variable name and the equal sign.