Results 1 to 2 of 2
For example, I have a text file with data which lists numerical values from two separate individuals
Code:
Person A
100
200
300
400
500
600
700
800
900
1000
...
- 03-11-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 2
[BASH] How to read multiple lines from a text file?
For example, I have a text file with data which lists numerical values from two separate individuals
How would I go about reading the values for each Person, then being able to perform mathematical equations for each Person (finding the sum for example) ?Code:Person A 100 200 300 400 500 600 700 800 900 1000 1100 1200 Person B 1200 1100 1000 900 800 700 600 500 400 300 200 100
Thanks.
- 03-12-2011 #2
Bash isn't really well suited to that, but awk will do it easily. You need just 2 lines in your awk script: one matching numeric lines which adds the numbers to your running total, the other matching text lines which prints the result and zeros the counter.
"I'm just a little old lady; don't try to dazzle me with jargon!"


Reply With Quote