顯示狀態1-處於"/"旋轉
#!/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"
