linux-tutorial/codes/shell/控制/捕捉脚本的退出.sh
2019-10-29 18:22:19 +08:00

14 lines
165 B
Bash

#!/usr/bin/env bash
# trapping the script exit
trap "echobyebye" EXIT
count=1
while [ $count -le 5 ]
do
echo "Loop #$count"
sleep 3
count=$[ $count + 1 ]
done