两种实现方式:
- shell脚本直接调用另一个脚本
- shell脚本新建终端并执行另一个脚本
1. shell脚本直接调用另一个脚本
shellPath.sh
# main shell script call other shell script
echo "main shell execute....[`date "+%Y-%m-%d %H:%M:%S"`]"
~/Desktop/otherShell.sh
echo "main continue...[`date "+%Y-%m-%d %H:%M:%S"`]"
# other shell
sleep 3
echo "other shell execute....[`date "+%Y-%m-%d %H:%M:%S"`]"
2. shell脚本新建终端并执行另一个脚本
open -a Terminal.app shellPath.sh
注:
在开启另一个终端运行脚本后,此脚本便继续运行后面的命令,不会等待另一个脚本运行完.
# main shell script call other shell script
echo "main shell execute....[`date "+%Y-%m-%d %H:%M:%S"`]"
open -a Terminal.app ~/Desktop/otherShell.sh
echo "main continue...[`date "+%Y-%m-%d %H:%M:%S"`]"
# other shell
sleep 3
echo "other shell execute....[`date "+%Y-%m-%d %H:%M:%S"`]"
版权声明:本文为sinat_38483976原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。