shell脚本捕获到CTRL+C终止后执行补救命令 1、直接上代码 点击查看代码 # cat test_trap.sh#!/bin/bashfunc(){echo'exit abnormal'}trapfunc SIGINT#SIGINT也可以简写为INT或者信号数字2sleep15echo'exit normal 2、看看效果 正常运行结束 ![正常](https://img2022.cnblogs.com/blog/1813599/202205/1813599-2022...
/bin/bash 捕获ctrl+c信号时,执行echo命令 trap 'echo "you are typing ctrl-c ,sorry,script will not terminate"' INT 捕获Ctrl+\信号,执行echo trap 'echo "you are typing ctrl-\ ,sorry,script will not terminate"' QUIT 捕获ctrl+z信号,就会执行echo命令 (实测此处没有执行echo命令) trap 'echo "...