目录

shell 脚本执行

shell 脚本除了直接 ./test.sh 执行外,还可以用 sh 在子进程中执行、sh -x 打印执行过程便于调试、source 在父进程中执行,以及用 . 无需执行权限临时执行。

一、常见执行方式

1
./test.sh

二、其它执行方式

1
2
3
4
sh test.sh #在子进程中执行
sh -x test.sh #会在终端打印执行到命令,适合调试
source test.sh #test.sh在父进程中执行
. test.sh #不需要赋予执行权限,临时执行