I realise that this is a bit late, but I haven't checked this account for a while :)

perl -lane '$x+=$F[1];print "$F[0]\t$x"' < foo

(where foo is your original file)

cheers,
Darren

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



--
DOCOMO interTouch provides a full suite of integrated solutions to the
hospitality industry. With over 1000 employees operating in 63 countries,
DOCOMO interTouch is one of the world's largest hotel technology service
providers, backed by mobile communications leader NTT DOCOMO.
Email disclaimer - www.docomointertouch.com/Email_Disclaimer.aspx


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

Reply via email to