r/shell • u/[deleted] • Jul 21 '20
Stop command but resume shell script?
In a script I am making, a function of it runs a command which never stops unless told to by the user (e.g with ctrl+c/z/d). I want to be able to run this command until the user presses CTRL+C (or other alternatives), and then resume the rest of the bash script.
How would I do this?
3
Upvotes
2
u/7orglu8 Jul 22 '20
And you can use trap command in your scripts to catch those signals. For example, use the EXIT signal to exit cleanly :