分享四个进度条代码,shell脚本实现的进度条代码,效果不错。
例1,shell脚本实现的进度条。
复制代码代码示例:
#!/bin/sh
# b='' for ((i=0;$i<=100;i+=2)) do printf "progress:[%-50s]%d%%\r" $b $i sleep 0.1 b=#$b done echo
例2,shell脚本实现的进度条。
复制代码代码示例:
#!/bin/bash
# i=0 while [ $i -lt 20 ] do ((i++)) echo -ne "=>\033[s" echo -ne "\033[40;50H"$((i*5*100/100))%"\033[u\033[1D" usleep 50000 done echo
例3,shell脚本实现的进度条。
复制代码代码示例:
#!/bin/bash
# COUNTER=0 _R=0 _C=`tput cols` _PROCEC=`tput cols` tput cup $_C $_R printf "[" while [ $COUNTER -lt 100 ] do COUNTER=`expr $COUNTER + 1` sleep 0.1 printf "=>" _R=`expr $_R + 1` _C=`expr $_C + 1` tput cup $_PROCEC 101 printf "]%d%%" $COUNTER tput cup $_C $_R done printf "\n"
例4,shell脚本实现的进度条。
复制代码代码示例:
#!/bin/bash
# i=0 while [ $i -lt 50 ] do ((i++)) for j in '-' '\\' '|' '/' do echo -ne "$j\033[s" echo -ne "\033[40;50H"$((i*5*100/100))%"\033[u\033[1D" usleep 50000 done done echo (责任编辑:IT) |