Trapping ctrl-c in Bash

Trapping ctrl-c in Bash

# !/ bin / bash

# trap ctrl
- c and call ctrl_c()
trap ctrl_c INT

function ctrl_c() {
        echo 
" ** Trapped CTRL-C "
}

for  i  in  `seq  1   5 `;  do
    sleep 
1
    echo 
- " . "
done

你可能感兴趣的:(Trapping ctrl-c in Bash)