wait - is a built-in command of Linux that waits for completing any running process.

syntax
$ wait [options] ID

To wait for a background process with PID 7872
$ wait 7872

$ rsync -a /home/Documents /tmp/Documents &
[1] 78724

$ wait %1

To make waits for any multiple background job to complete and return the job exit status
$ wait -n <pid_1> <pid_2> <pid_3>

wait command in shell scripts
$ vim wait.sh
#!/bin/bash
sleep 20 &
process_id=$!
echo "PID: $process_id"
wait $process_id
echo "Exit status: $?"
:x

$ sh wait.sh



regards,
T.Dhanasekar