shell递归一例
用递归写的一个光标旋转的小脚本
[root@maint-app-108 recurse]# cat cursor.sh
cursor () { #{{{
message="$1"
count="$2"
for item in "|" "/" "-" "\\"
do
printf "\r${item} ${message} $count"
usleep 50000
done
cursor waiting $((count+1))
}
cursor waiting 1
[root@maint-app-108 cursor]# 用递归做这种无限循环最后脚本会退出,下面这个while :不会退出。 [root@maint-app-108 cursor]# cat cursor.sh
cursor () { #{{{
message="$1"
for item in "|" "/" "-" "\\"
do
printf "\r${item} ${message}"
usleep 50000
done
}
while :
do
cursor waiting
done