With a google link for the countdown, I'm trying to make a different conclusion. that is, showing the remaining seconds to continue: 20. Each time the countdown reaches 10 .., it counts down as 90, 80, 70, 60, 50, 40, 30, 20, 10. There are many examples of data using clear in while loop, but I don’t want to clear my scripts of other outputs when displaying the countdown time.
I would like to know where I am making a mistake.
function countdown ()
{
if (($# != 1)) || [[ $1 = *[![:digit:]]* ]]; then
echo "Usage: countdown seconds";
return;
fi;
local t=$1 remaining=$1;
SECONDS=0;
while sleep .2; do
printf '\rseconds remaining to proceed: '"$remaining";
if (( (remaining=t-SECONDS) <=0 )); then
printf '\rseconds remaining to proceed' 0;
break;
fi;
done
}
source
share