Hello. I am pretty new to unix and shell scripting and I was wondering if there might be a way to banner a countdown timer inside a script. We currently have an existing script that does a 2 minute sleep but thought it might be fun to actually make it banner a countdown timer until it is finished. Is this possible?
1 Like
What does "banner" mean when used as a verb here?
T=$((SECONDS+(2*60)))
while ((T > SECONDS))
do
# \r returns to the beginning of the line and overwrites.
printf "\r%02d:%02d" $(( (T-SECONDS)/60 )) $(( (T-SECONDS)%60 ))
sleep 1
done
echo
Would this come close to what you envision?
SEC=10
printf -- '------------------------------------\n\e[s'
while (( --SEC )); do printf '\e[uwaiting %2d seconds\n' $SEC; sleep 1; done
printf -- '------------------------------------\n'
The following runs with ksh or bash:
SEC=10; while (( SEC -= 1 )); do clear; ~tool/bin/banner " $SEC"; sleep 1; done
If your OS ships without a banner program, download and compile one!