I've always wondered how installation scripts created spinners, and counters, etc.. So, I played around and come up with this
#!/bin/bash
TIMER=60
DIVISOR=1
COUNTER=${TIMER}
C=0
while [ $COUNTER -gt 0 ]
do
case "$(($C % 4))" in
0) char="/"
;;
1) char="-"
;;
2) char="\\"
;;
3) char="|"
;;
esac
echo -ne "${char} -- ${COUNTER} \r"
COUNTER=$[$COUNTER-$DIVISOR]
C=$[$C+1]
sleep $DIVISOR
done
echo -ne '\n'
#!/bin/bash
TIMER=60
DIVISOR=1
COUNTER=${TIMER}
C=0
while [ $COUNTER -gt 0 ]
do
case "$(($C % 4))" in
0) char="/"
;;
1) char="-"
;;
2) char="\\"
;;
3) char="|"
;;
esac
echo -ne "${char} -- ${COUNTER} \r"
COUNTER=$[$COUNTER-$DIVISOR]
C=$[$C+1]
sleep $DIVISOR
done
echo -ne '\n'
Comments
Post a Comment