捕捉脚本的退出

5年以前  |  阅读数:474 次  |  编程语言:Shell 
#!/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

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8