执行shell脚本的三种方式

不需要执行权限的

1.

点号或者source

. test.sh

或者

source test.sh

注:这种方式不会产生子shell进程,仍在当前shell进程下

2.

bash或相对路径的三种写法者sh

bash test.sh

或者

sh test.sh

需要执行权限dw相对路径

3.

直接使用相对路径或者绝对路径

./test.sh

或者

/root/test.sh

注:方式2和方式3会产生产生子进程