Skip to content

Instantly share code, notes, and snippets.

@fel-cesar
Created February 14, 2019 20:59
Show Gist options
  • Save fel-cesar/ac71c58dfcd04457b0e6ab36b1c362f6 to your computer and use it in GitHub Desktop.
Save fel-cesar/ac71c58dfcd04457b0e6ab36b1c362f6 to your computer and use it in GitHub Desktop.
Sample script to demonstrate how to capture a 'trap' command in terminal
#!/bin/bash
# trap ctrl-c and call ctrl_c()
trap ctrl_c INT
function ctrl_c() {
echo "** Trapped CTRL-C"
exit 1
}
for i in `seq 1 5`; do
sleep 1
echo -n "."
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment