Is it possible to insert the following code ( a timer ) in the dialog progress bar ?

date1=`date +%s`; 
   while true; do 
   echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r"; 


  dialog --title "File upgrade" --gauge "Please wait..." 10 70 0

My goal is to view the timer clock in the progress bar window. The clock should stop when the progress bar ended.


I would avoid any arithmetic operation, and use --gauge as documented ("new percentages are read from standard input"):

for ((i=0;i<=100;i+=10)); do echo $i; sleep 1; done | dialog --gauge "Please wait 10 seconds." 0 0
  • {, } => do, done ? – PSkocik Sep 16 '15 at 9:43
  • You can use both syntaxes in Bash, but this one allows to specify the increment. – pedroapero Sep 16 '15 at 10:11
  • Maybe you can :D. I would love to use the curly brace syntax but bash 4.3.11 won't allow me to. Neither will ksh, csh or dash. Zsh will. Aren't you on zsh? – PSkocik Sep 16 '15 at 10:25
  • 1
    You're totally right, I've tested it using zsh. I use the curly braces in scripts, but it seems it doesn't work on a single line... I've updated the answer accordingly. – pedroapero Sep 16 '15 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.