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
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.