Shell动态条进度

代码:

#!/bin/bash



function dongtai(){
i=0
bar=''
index=0
arr=( "|" "/" "-" "\\" )

while [ $i -le 100 ]
do
    let index=index%4
    printf "[+]准备开始:[%-100s][%d%%][\e[43;46;1m%c\e[0m]\r" "$bar" "$i" "${arr[$index]}"
    let i++
    let index++
    usleep 30000
    bar+='#'
    clear
done
}



dongtai
echo -e "[+]准备完成"

运行结果:

你可能感兴趣的:(shell,服务器,linux,shell)