I have a while loop to count to 5 and echo "Done" when finished. I want to be able to execute the script in the background with "&" and continuing issuing commands while it runs.
But when it's done, I want it make itself the foreground process before echoing "Done". After that, I would expect it to show a new command prompt line. I can just echo "\nDone", and I understand why running it in the background would just print the output and not end/start a new prompt. But I'm wondering if it's possible to basically kind of "merge jobs" back together before ending, and if I could apply that elsewhere, with built-in job control in my scripts.
This is not a practical problem, just curious.
i=0
while [ $i -lt 5 ]
do
let i+=1
sleep 1
done
fg
echo "Done"