pid_list="21232 21231 43432" # same can be put in an array as well
I am running a bunch of commands in the background and obtained its pids using $i. How can i check whether it is finished or not.
Try this:
ps -ef | egrep $(echo $pid_list | sed 's/ /|/g') | grep -v grep | wc -l
If the output is 0, that means the processes are finished.