Shell脚本启动方式
将shell脚本作为程序运行
chmod +x test.sh
./test.sh
将shell脚本作为参数传递给Bash解释器
/bin/bash test.sh
使用这种方式,不需要在脚本开头写#!/bin/bash,写了也没什么用
在当前进程中运行shell脚本
使用source命令。source是shell的内建命令,会依次读取脚本内容,并执行。使用如下
- source xxx.sh
- . test.sh:
.
和test.sh
之间有一个空格!
...