不多说,直接上脚本。
# processbar <current> <total> processbar() { local current=$1; local total=$2; local maxlen=80; local barlen=66; local perclen=14; local format="%-${barlen}s%$((maxlen-barlen))s" local perc="[$current/$total]" local progress=$((current*barlen/total)) local prog=$(for i in `seq 0 $progress`; do printf '#'; done) printf "\r$format" $prog $perc } # Usage(Client) for i in `seq 1 10`; do processbar $i 10 sleep 1 done echo ""
BASH Shell 简易进度条小函数
时间: 2024-10-09 06:59:06