Wait for job completion and return exit status.
Waits for each process identified by an ID, which may be a process ID or a
job specification, and reports its termination status. If ID is not
given, waits for all currently active child processes, and the return
status is zero. If ID is a a job specification, waits for all processes
in that job's pipeline.
If the -n option is supplied, waits for the next job to terminate and
returns its exit status.
Exit Status:
Returns the status of the last ID; fails if ID is invalid or an invalid
option is given.
wait命令用来等待指令的指令,直到其执行完毕后返回终端。该指令常用于shell脚本编程中,待指定的指令执行完成后,才会继续执行后面的任务。该指令等待作业时,在作业标识号前必须添加备份号"%"
wait [作业指示或进程号]
1.等待作业号或者进程号制定的进程退出,返回最后一个作业或进程的退出状态状态。如果没有制定参数,则等待所有子进程的退出,其退出状态为0.
2.如果是shell中等待使用wait,则不会等待调用函数中子任务。在函数中使用wait,则只等待函数中启动的后台子任务。
3.在shell中使用wait命令,相当于高级语言里的多线程同步。
wait命令经过查找资料发现用于在shell多线程的编程中