Article 57YZK [Shell Script] - the digits appear wrong in the printf

[Shell Script] - the digits appear wrong in the printf

by
Pinguino99
from LinuxQuestions.org on (#57YZK)
how do I make the countdown digits appear right?
if I use only $1 it doesn't work correctly because the colon don't appear

Code:#!/bin/bash

# usage
# run script specifying hour, minute and second, example of a five-minute countdown: ./countdown.sh 00:05:00

function countdown
{
cols=$( tput cols )
rows=$( tput lines )
middle_row=$(( $rows / 2 ))
middle_col=$(( ($cols /2) - 4 ))

local OLD_IFS="${IFS}"
IFS=":"
local ARR=( $1 )
local SECONDS=$(( (ARR[0] * 60 * 60) + (ARR[1] * 60) + ARR[2] ))
local START=$(date +%s)
local END=$((START + SECONDS))
local CUR=$START

while [[ $CUR -lt $END ]]
do
CUR=$(date +%s)
LEFT=$((END-CUR))
tput cup $middle_row $middle_col
echo -ne "$(printf %02d:%02d:%02d)\e" \
$((LEFT/3600)) $(( (LEFT/60)%60)) $((LEFT%60))

sleep 1
done
IFS="${OLD_IFS}"
echo " "
}
clear

countdown "$1"latest?d=yIl2AUoC8zA latest?i=sKRUjwsTqFQ:mDBI_q2CbYE:F7zBnMy latest?i=sKRUjwsTqFQ:mDBI_q2CbYE:V_sGLiP latest?d=qj6IDK7rITs latest?i=sKRUjwsTqFQ:mDBI_q2CbYE:gIN9vFwsKRUjwsTqFQ
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments