shell 实现进度条
#!/bin/sh sleep 10 & pid=$! # Process Id of the previous running command spin='-\|/' i=0 while kill -0 $pid 2>/dev/null do i=$(( (i+1) %4 )) printf "\r[${spin:$i:1}]" sleep .1 done
显示状态2-进度条前进状态
#!/bin/sh j='' for ((i=0;$i<=100;i+=2)) do printf "progress:[%-50s]%d%%\r" $j $i sleep 0.1 j=#$j done echo
显示状态3-进度条前进+处于"/"旋转
#!/bin/bash i=0 j='#' k=('|' '\' '-' '/') l=0 while [ $i -le 25 ] do printf "progress:[%-25s][%d%%][%c]\r" $j $(($i*4)) ${k[$l]} j+='#' let i++ let l=i%4 sleep 0.1 done printf "\n"
努力让自己变得不那么low