10 More Discussions You Might Find Interesting
1. 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
2. Shell Programming and Scripting
I have a file with the following format
AAAAA 1.34B 0.76B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.00B 0.90B 0.00B 0.00B 0.46B 0.00B 0.03B 0.00B ... (4 Replies)
Discussion started by: ncwxpanther
4 Replies
3. UNIX for Dummies Questions & Answers
Can anyone tell me how sum values in each record of a file and append that value to the end? For instance a typical record will be:
FY12,Budget,771100,,,,,,,,,250,-250
I'd like the record to become
FY12,Budget,771100,,,,,,,,,250,-250,0
which can be put into another file.
Thank you. (6 Replies)
Discussion started by: LearningLinux2
6 Replies
4. Shell Programming and Scripting
Hey,
I am gettin a bit crazy with my script. I have several input datas with the same name (5.ill) in different folders (daysim_01, daysim_02, etc.). The 4. column of each of the data has to be summed with each other and then hass to be written in one new file.
So file1:
1 1 0 1
2 1 1 2 ... (7 Replies)
Discussion started by: ergy1983
7 Replies
5. Shell Programming and Scripting
I'm new to perl programming. I've a csv file as below.
20100221, abc_1, 200
20100221, abc_4, 350
20100221, opq_3, 200
20100221, abc_5, 220
20100221, xyz_1, 500
20100221, abc_2, 500
20100221, abc_3, 100
20100221, xyz_2, 700
20100221, opq_2, 350
20100221, xyz_3, 100
20100221, opq_1, 230... (8 Replies)
Discussion started by: ganapati
8 Replies
6. 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
7. Shell Programming and Scripting
I am trying to take two files and add the numbers from each. There is a total of 5192 numbers in each file and I want to add them row by row... ie. first row of file 1 + first row of file 2 = first row of output. Eventually I will be summing 40401 of these files together but starting with 2 just... (21 Replies)
Discussion started by: pattywac
21 Replies
8. Shell Programming and Scripting
Hi All,
Here is the problem:
The input file is like as per below. Each record has 30 chars in total. Have to add the first 17 and the next 13 and append the output. Total records can vary.
000000004728800000000000003908
000000003005100000000000002484
000000002602200000000000002151... (5 Replies)
Discussion started by: er_ashu
5 Replies
9. 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
10. 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