[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: A question about bash scripting



On Mon, 2012-10-29 at 15:00 -0400, Wolf Halton wrote:
> On Mon, Oct 29, 2012 at 6:57 AM, Ralf Mardorf
> <ralf.mardorf@alice-dsl.net> wrote:
> > Hi :)
> >
> > how can I get rid of the variable "seconds"?
> >
> > ((seconds=(done-started)-(((done-started)/60)*60)+100))
> > min_sec=$(((done-started)/60))":"${seconds: -2}
> >                                    ^^^^^^^ the math should replace the
> > variable.
> >
> > ### Killall and Restore session
> >  started=$(date +%s)
> >  bash "$song_path/session/start-session-$startversion"
> >
> >  ### Time
> >  month=$(date +%B)
> >  mon=$(date +%b)
> >  d_y_t=$(date '+/%d/%Y %T')
> >  done=$(date +%s)
> >  ((seconds=(done-started)-(((done-started)/60)*60)+100))
> >  min_sec=$(((done-started)/60))":"${seconds: -2}
> >  echo
> >  echo    "Attended time to restore session:         $min_sec"
> >  echo -n "Session restored at " ; printf %9.9s $month ; echo $d_y_t
> >  echo
> >
> > TIA,
> > Ralf
> >
> >
> 
> Ralf,
> I don't understand.
> What are you wanting to do with the script?
> If you don't like the name of the variable, make up another one.
> 
> Wolf

This part of a larger script is a stopwatch and I want the math
((done-started)-(((done-started)/60)*60)+100))   inside the formatted
string   ${seconds: -2}   , instead of a variable.

Something similar to
${((done-started)-(((done-started)/60)*60)+100)): -2}

Similar, because I'm missing something.

Regards,
Ralf

PS: In German:
Das "${seconds: -2}" formatiert den String und statt "seconds" soll dort
((done-started)-(((done-started)/60)*60)+100)) eingefügt werden. Doch
wie?







Reply to: