05-06-2008
Namish,
Thansk for your reponse but I want the follwoing.
file.txt
111111111111111112000000000000
111111111111111112000000000000
111111111111111112000000000000
111111111111111112000000000000
output should be
444444444444444448000000000000
Sorry for any confusion.
Thanks
Ashu
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Friends
How to do sum on a column?
I have a file like:
FRED 500.01 TX
SMITH 50.10 NY
HARRY 5.00 CA
555.11
Sum on second column.
I am trying using nawk like
nawk 'BEGIN {FS="|"}; {printf $1"+"}'
Thanks a lot for your help
S :) (2 Replies)
Discussion started by: sbasetty
2 Replies
2. UNIX for Dummies Questions & Answers
I have a text file with two columns
the first column is an integer and the second column is date
how do i sum up the first column according to the date
example
123 jan1
232 jan1
473 jan2
467 jan2
356 jan3
376 jan3
my result should be
355 jan1
940 jan2
732 jan3
how do i... (2 Replies)
Discussion started by: ramky79
2 Replies
3. Shell Programming and Scripting
Hi All,
I have a file like -
num.txt
12, 34, 65, line1
34, 65, 89, line2
43, 65, 77, line3
I want to do two things -
1. Add first three columns of each line and print the line with largest value.
i.e. (12+34+65) for 1st line and so on.
2. Add middle column of each line i.e.... (3 Replies)
Discussion started by: asahlot
3 Replies
4. Shell Programming and Scripting
Hi
I need to sum of sub total amounts. Please any ideas
file1.txt
type: xx
xyz 200 300
xyz1 300 400
Sub total 500 700
type:yy
abc 200 300
abc1 100 100
Sub total ... (4 Replies)
Discussion started by: mohan705
4 Replies
5. Shell Programming and Scripting
Basically I have to process a text file which has been sorted this way:
John 12
John 13
John 10
John 900
Peter 20
Peter 30
Peter 32
The first column is a name, and the second an arbitrary value, both delimited by a space. How can I sum them up such that it would become:
John 935... (2 Replies)
Discussion started by: Dwee
2 Replies
6. Shell Programming and Scripting
I have two files
hhhh 3674.00
a 75 1535 183 2134 291 2452 442 2738 704 3048
a 1007 3549 1282 4413 1494 5001 1631 5217 1954 5610
a 2540 5832 3248 6080 3629 6264 4851 6600 7004 6985
... (4 Replies)
Discussion started by: Indra2011
4 Replies
7. Shell Programming and Scripting
My file is something like this :
03.097
03.094
03.093
03.095
03.091
04.089
06.093
07.225
08.196
06.097
06.094
05.096
04.086
I'd like to sum it from a given line to another one , e.g.: from line 10 until line 20
What s the awk way solving this ? (1 Reply)
Discussion started by: firelink
1 Replies
8. Shell Programming and Scripting
I'm trying to sum a text file using AWK. Here is an example of the file:
600|3H68| 46
600|3H69| 46
600|3H6F| 290
600|3H6G| 24
600|3HDY| 1
600|3HDY| 3
600|3HE0| 1
600|3HE0| 3
I would like to sum the third field if the first... (7 Replies)
Discussion started by: Drenhead
7 Replies
9. Shell Programming and Scripting
I was playing around to see how stuff works, and was trying to sum all fields in a file.
cat file
1 2 3 4
5 6 7 8
9 10 11 12
I made this script:
awk 'BEGIN {OFS=RS}{$1=$1}{s+=$0} END {print "sum="s}' file
This gives 15, why not 78?
I test it like this
awk 'BEGIN... (5 Replies)
Discussion started by: Jotne
5 Replies
10. Shell Programming and Scripting
hi All,
i have a file in which only one column is there.,
test.txt
======
-900.01
-900.02
-900.03
-900.04
-900.05
-900.06
-900.07
-900.08
-900.09
900.01
900.02
900.03
900.04
900.05 (4 Replies)
Discussion started by: mechvijays
4 Replies