偷瓜的贼 发表于 2018-8-28 07:11:17

执行shell脚本的方式

  执行shell脚本有以下3种方式:

[*]  bash xxxxx.sh或者sh xxxxx.sh(推荐使用)
[*]  path/xxxxx.sh或者./xxxxx.sh(当前路径下执行脚本)
[*]  source xxxxx.sh或者. xxxxx.sh(点后面有个空格。此种方式可以把自身shell变量的值
  传递给父shell使用)。
  第一种方式是当shell脚本没有可执行权限的时候用;
  第二种方式,当chmod o+x xxxxx.sh或者chmod 755 xxxxx.sh赋予shell脚本可执行权限的
  的时候,可以用第二种方法。

页: [1]
查看完整版本: 执行shell脚本的方式