#!/usr/bin/env bash
countdown() {
i=$1
while [ $i -gt 0 ]; do
printf "Starting in %d...\n" $i
sleep 1
i=$(( i - 1 ))
done
}
countdown 3
Agora, se você quiser ser chique, vale a pena analisar tput
:
tcountdown() {
i=$1
clear
while [ $i -gt 0 ]; do
tput cup $(( i - 1 )) 40
printf $i
sleep 1
i=$(( i - 1 ))
done
tput cup 0 40
printf "0\n"
}