ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a text file (see below) that I want to perform some simple addition on. I want to take the number in the "CUM.RE.WORTH" column (19.3000), add it to the number in the "RE.WORTH" column, and put the result on the next line of the "CUM.RE.WORTH" column. I know how to get awk to read specific columns, but I'm not sure how to get it to start reading a column at a specific line, or append data to a specific column, etc.
Would awk be a good tool for this, or should I use something else?
Code:
REACTIVITY EFFECTS OF LOADING CHANGES
DATE OF SHUTDOWN : 2009-02-08
==========================================================================
| SITE | TYPE OF LOADING | RE.WORTH | CUM.RE.WORTH |
| | | ( mk ) | ( mk ) |
==========================================================================
REACTIVITY AT S/D 19.3000
M19 MRZ469 OUT -1.0000
M19 MRR401 IN 1.0000
M13 MRL474 OUT -1.0000
M13 MRX402 IN 1.0000
L22 MRG475 OUT -1.0000
L22 MRJ403 IN 1.0000
M17 URR8553-4 OUT 0.8000
M17 URR8573-4 IN -0.8000
L18 MRM477 OUT -1.0000
L18 MRS404 IN 1.0000
M15 MRV478 OUT -1.0000
M15 MRW405 IN 1.0000
L08 S340B267 OUT -7.3000
L28 FL1608 OUT -2.5000
L28 FL1580 IN 4.2000
M17 DMY-5 OUT 0.2000
K15 URR8570-6 OUT 0.8000
K15 DMY-5 IN -0.2000
M17 URR8570-5 IN -0.8000
L08 HFD3B IN 2.0000
B11 FL1633 OUT -3.2000
B11 FLNEW IN 4.4000
L04 FL1564 OUT -1.4000
L04 FL1633 IN 4.9000
K17 FL1605 OUT -4.1000
K17 FL1599 IN 5.9000
(I think) I see what you're asking. You want to have a running total on the far right column? How about posting what you've tried so far?
To answer your more general question, you could probably kludge together an awk script to handle this problem. (i.e. I don't think it's beyond awk's capabilities.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.