# Start your long-running task in the background (&), then capture the Process ID of the task
sleep 5 &
PID=$!
# Loop and print dots while the process is running. Note use of printf which won't add a newline
# character to the dot, so it just appends each one on the same line. Kill -0 just tests if
# the PID still exists; when it no long does because the background process finished, the loop ends.
while kill -0 $PID 2>/dev/null; do
printf "."
sleep 0.5
done
echo " Done!"
2026/08/17