Yanto,

There are many ways to it. The awk version of the solution will be like:

awk '{sum+=$2;print $1,sum}' inputfile


Where "inputfile" is your input. assume that the file contains lines of
similar pattern.

Regards


On Fri, 2008-06-20 at 16:32 +0200, Yanto Young wrote:
> Hi guys,
> 
> I would like to know if there's a quick and dirty method (using
> bash/sed/awk) to perform the following:
> 
> Original file:
> *******************
> t=0  1
> t=1  1
> t=2  -1
> t=3  1
> t=4  1
> t=5  -1
> *******************
> 
> Desired result:
> *******************
> t=0  1
> t=1  2
> t=2  1
> t=3  2
> t=4  3
> t=5  2
> *******************
> 
> that is, I would like to perform cumulative addition on the second column.
> 
> 
> Thanks.
> 
> Best regards,
> Yanto
> 
> _______________________________________________
> Slugnet mailing list
> [email protected]
> http://wiki.lugs.org.sg/LugsMailingListFaq
> http://www.lugs.org.sg/mailman/listinfo/slugnet


_______________________________________________
Slugnet mailing list
[email protected]
http://wiki.lugs.org.sg/LugsMailingListFaq
http://www.lugs.org.sg/mailman/listinfo/slugnet

Reply via email to