I've written a shell script for testing an API that copies files and echoes its progress after each one.
There is a two second sleep between each copy, so I would like to add the ability to press any key to pause the script to allow deeper testing. Then press any key to resume.
How can I add this in as few lines as possible?
Best Answer
You don't need to add something to your script. The shell allows such a functionality.
T
, stopped)jobs
in the terminal or list all stopped jobs.fg
(foreground). It resumes the job back into the foreground process group and the jobs continues running.See an example: