linux - How do I write a script to run multiple processes in the background and have additional commands run once each individual command completes? -
i'm trying following in bash script:
for x in b c; echo foo $x; sleep 5 & y=$! ; (wait $y && echo bar $x) & done
is possible, without adding complexity (the above example of course not work)?
edit:
of course in reality, echo foo $x; sleep 5
example, copying large file or compiling big, , second operation operations depend on first.
maybe missing using ()
s , putting &
on entire sub group command...
for in 1 2 3; (echo $i; sleep 5; echo end $i)& done
Comments
Post a Comment