拥有一个执行另一个shell脚本的shell脚本。
第二个shell脚本开始运行后,我需要执行一些命令,最后退出第二个shell
进入父shell后,进行下游处理。我如何实现这一目标?
Parent.sh
Child.sh
Command1
Command2
exit
Parent Command1
Parent Command2
答案 0 :(得分:0)
父:
#!/bin/bash
echo Parent: I am the parent
child
echo Parent: Performing Command1
echo Parent: Performing Command2
子:
#!/bin/bash
echo Child: running and about to perform command1 and command2 in subshell
(command1; command2)
echo Child: command1 and command2 complete
答案 1 :(得分:0)
parent.sh
#!/bin/sh
echo Parent
. ./child.sh
echo "this won't be executed"
child.sh
#!/bin/sh
echo Child
exit
答案 2 :(得分:0)