This question already has answers here:
Execute multiple shell scripts concurrently

(5个答案)


5年前关闭。




有没有一种方法可以同时运行多个命令,但是直到两个命令都完成后才能继续运行?我一直在尝试使用与以下类似的指令,但是两者都需要很长时间才能完成,并且如果我可以同时运行它们会更好(不能使用&在后台运行它,因为下一步需要所有输出文件)
sed -i 's/x/y/' file1
grep 'pattern' file2 > file3

最佳答案

这可能是您想要的:

sed -i 's/x/y/' file1 &
grep 'pattern' file2 > file3 &
wait

关于linux - Bash-同时运行多个命令,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30735619/

10-14 16:29
查看更多