[ale] Awk question
Richard Bronosky
Richard at Bronosky.com
Sun Feb 5 19:19:37 EST 2012
No response? Really? It was perfect, BTW.
On Feb 3, 2012 6:37 PM, "Richard Bronosky" <Richard at bronosky.com> wrote:
> Close but you ignited the math in the requirements.
>
> Here us the answer:
> awk '{prev=last; last=$2} END {print (last-prev)/prev}' filename
>
> This is untested because I wrote it on a phone.
>
> On Feb 3, 2012 4:26 PM, "Erik Mathis" <erik at mathists.com> wrote:
> >
> > awk '{sum+=$2} END {print sum}' filename
> > 310
> > awk '{subt-=$2} END {print subt}' filename
> > -310
> >
> > Stolen and hacked from http://www.commandlinefu.com
> >
> > -Erik-
> >
> > On Fri, Feb 3, 2012 at 1:51 PM, Randy Ramsdell <rramsdell at activedg.com>
> wrote:
> > > I need to parse a file and then subtract next to last line field $2
> > > from the last line field $2 using awk and then convert this number to a
> > > percent.
> > >
> > > Data:
> > >
> > > $date 100
> > > $date 103
> > > $date 107
> > >
> > > So ... ( 107 - 103 ) / 103 ...
> > >
> > > Clues?
> > > _______________________________________________
> > > Ale mailing list
> > > Ale at ale.org
> > > http://mail.ale.org/mailman/listinfo/ale
> > > See JOBS, ANNOUNCE and SCHOOLS lists at
> > > http://mail.ale.org/mailman/listinfo
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://mail.ale.org/mailman/listinfo/ale
> > See JOBS, ANNOUNCE and SCHOOLS lists at
> > http://mail.ale.org/mailman/listinfo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20120205/9dc39c74/attachment-0001.html
More information about the Ale
mailing list