Wait for the process to finish executing and return
wait command is a command used to wait for instructions until it is completed and returns to the terminal. This instruction is often used in shell script programming. After the execution of the specified instruction is completed, the subsequent tasks will continue to be executed. When this command waits for a job, a percent sign "%" must be added before the job identification number.
wait(parameter)
Process or job ID: Specify the process number or job number.
Use the command wait to wait for the job with job number 1 to complete before returning. Enter the following command:
Run a sleep process
sleep 10s &
[1] 27156
Specify job number
wait %1 #Wait for the job with job number 1 to complete
[1]+ Done sleep 10s
Specify process number
wait 27156
[1]+ Done sleep 10s
Output the instructions for the currently existing job number, as shown below: