1. As an executable program
Save the above code as test.sh and CD to the appropriate directory:
+./test. #使脚本具有执行权限./test. #执行脚本
Note, be sure to write ./test.sh, not test.sh, run other binary programs also, the direct write Test.sh,linux system will go to the PATH to find there is no test.sh, and only/bin,/sbin, /usr/bin,/usr/sbin wait in path, your current directory is usually not in path, so write test.sh will not find the command, to use./test.sh tells the system that it is looking in the current directory.
2. As an interpreter parameter
This works by running the interpreter directly, whose parameters are the file names of the shell scripts, such as:
/bin/sh test. SH/bin/php test. PHP
The script that runs this way does not need to specify the interpreter information in the first line, and it is useless to write.
There are two ways to run a Shell script: