sh文件执行的3种方式

1. 用绝对路径或相对路径执行

/xxx/xx/test.sh 或 ./test.sh, 要求sh文件必须有可执行权限,可以用命令 chmod a+x test.sh来添加

2. 用bash或sh来执行

bash test.sh 或 sh test.sh

3. 用source 或 . 来执行

source test.sh 或 . test.sh 这样的一大特点是,在本shell执行,前面的方式都是在本shell的子shell中执行,不能获取sh文件中的变量

 


参考:https://www.cnblogs.com/zhj868/p/13123752.html

posted @ 2020-08-06 20:52  全玉  阅读(13159)  评论(0编辑  收藏  举报