On Monday, October 29, 2012 03:26:20 PM Ralf Mardorf wrote:
> On Mon, 2012-10-29 at 15:00 -0400, Wolf Halton wrote:
> > On Mon, Oct 29, 2012 at 6:57 AM, Ralf Mardorf
> >
> > <[email protected]> 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.
You missed the $((...)) syntax as exemplified by the '(done-started)/60' just
before it:
min_sec=$(((done-started)/60))":"
min_sec=${min_sec}$(((done-started)-(((done-started)/60)*60)+100))