Tsallaka zuwa abun ciki
Justice Tech School

Jobs and Processes

& runs in the background, wait waits for it and $! is its pid.

Example
sleep 0.2 &
pid=$!
wait $pid
echo "finished: $?"
( echo sub; exit 2 )
echo "sub status $?"

Result

finished: 0
sub
sub status 2

Exercise

Run in background.

sleep 1 

Quiz Test

What does wait do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.