linux-tutorial/codes/shell/示例脚本/控制/捕捉脚本的退出.sh

14 lines
158 B
Bash

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