方法一:
# 切换到shell脚本所在目录,且该脚本具备可执行权限
./test.sh
方法二
# 直接使用bash或sh来执行shell脚本
bash test.sh
# 或
sh test.sh
方法三
. test.sh
方法四
source test.sh
本文介绍了四种执行shell脚本的方法:直接运行、通过bash或sh、 sourcing和不同路径执行。重点在于不同场景下的便捷操作和权限管理。
方法一:
# 切换到shell脚本所在目录,且该脚本具备可执行权限
./test.sh
方法二
# 直接使用bash或sh来执行shell脚本
bash test.sh
# 或
sh test.sh
方法三
. test.sh
方法四
source test.sh

被折叠的 条评论
为什么被折叠?