08-05-2008
sum of all matching rows using awk
I have file
"1","x1897"," 89.10"
"1","x2232"," -12.12"
"1","x1897"," 389.10"
"1","x2232"," 212.12"
"1","x1897"," 19.10"
"1","x2232"," 2.12"
i want to add all 3 rd column rows (they have spaces also)for x1
and sum of 3rd column rows for x2 separately.
I am very bad at awk. can some one help me ?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi guys, i have been struggling to achieve the following and therefor looking for some help.
I am trying to write something that will summerize the following output from my switches for daily totals.
Basicly if $1 $2 $3 doesnt change, we can keep adding up $4. Probably would use a awk print end... (3 Replies)
Discussion started by: Wratholix
3 Replies
2. Shell Programming and Scripting
I have a file with 1000+ columns of data. I need to sum each row (not column). How can I do this with an awk one-liner?
Thank you
Example file:
1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3 3
The output should be:
10
20
30 (13 Replies)
Discussion started by: jm4smtddd
13 Replies
3. UNIX for Dummies Questions & Answers
Hi All,
I have the following input which i want to process using AWK.
Rows,NC,amount
1,1202,0.192387
2,1201,0.111111
3,1201,0.123456
i want the following output
count of rows = 3 ,sum of amount = 0.426954
Many thanks (2 Replies)
Discussion started by: pistachio
2 Replies
4. UNIX for Dummies Questions & Answers
Hi,
I have a file like this one
h1 4.70650E-04 4.70650E-04 4.70650E-04
h2 1.92912E-04 1.92912E-04 1.92912E-04
h3A 3.10160E-11 2.94562E-11 2.78458E-11
h4 0.00000E+00 0.00000E+00 0.00000E+00
h1 1.18164E-12 2.74150E-12 4.35187E-12
h1 7.60813E-01 7.60813E-01 7.60813E-01... (5 Replies)
Discussion started by: f_o_555
5 Replies
5. Shell Programming and Scripting
Hi All,
I have the following output file created as a result of one script called pattern_daily.log
$ cat pattern_daily.log
Approved|2|Wed, Oct 24, 2012 11:21:09 AM
Declined|1|Wed, Oct 24, 2012 11:21:15 AM
Approved|2|Wed, Oct 24, 2012 11:24:08 AM
Declined|1|Wed, Oct 24, 2012 11:24:18 AM... (4 Replies)
Discussion started by: Gem_In_I
4 Replies
6. UNIX for Dummies Questions & Answers
grep -c 'avihai' 1.log
will give me count of 'avihai' in log
I want to have a list of files in the folder that show file name with count side by side.
Please advice (2 Replies)
Discussion started by: avihaimar
2 Replies
7. Shell Programming and Scripting
Hi all,
I have a large matrix of 720 x 25. I want to get sum of range of rows and columns. Like, I need sum of all columns and row number 2 to 21, then leaving 22nd row, again sum of all columns and row number 23 to 42 again leaving 43rd row and then sum of 44th to 63. Means I want to add all... (4 Replies)
Discussion started by: CAch
4 Replies
8. Shell Programming and Scripting
input:
chr1 1 2 3
chr1 1 2 4
chr1 2 4 5
chr2 3 6 9
chr2 3 6 10
Code:
awk '{a+=$4}END{for (i in a) print i,a}' input
Output:
chr112 7
chr236 19
chr124 5
Desired output:
chr1 1 2 7
chr2 3 6 19
chr1 2 4 5 (1 Reply)
Discussion started by: jacobs.smith
1 Replies
9. Shell Programming and Scripting
Hey guys, my first post here.
I'm trying to use awk to copy all matching paragraphs from one file
The file looks like this :
Test Case Number 990990003099
Card Type CCCC
Transaction Type Sale
Entry Mode Keyed
Account Number 4099562299219923
Transaction Amount 78.88
Description lorem... (2 Replies)
Discussion started by: awkawed
2 Replies
10. Shell Programming and Scripting
In the awk below I am trying to add a penalty to a score to each matching $1 in file2 based on the sum of $3+$4 (variable TL) from file1. Then the $4 value in file1 is divided by TL and multiplied by 100 (this valvue is variable S). Finally, $2 in file2 - S gives the updated $2 result in file2.... (2 Replies)
Discussion started by: cmccabe
2 Replies
UMCT(4) BSD Kernel Interfaces Manual UMCT(4)
NAME
umct -- Magic Control Technology USB-RS232 converter driver
SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file:
device umct
device ucom
Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5):
umct_load="YES"
DESCRIPTION
The umct driver provides support for USB to RS-232 converters based on the Magic Control Technology USB-232 design. These devices support
most of the standard RS-232 features including baud rates ranging from 300 to 115200 bits per second. However, neither hardware nor software
flow control seems to be supported.
Access to devices under this driver is via the ucom(4) framework and device nodes.
HARDWARE
The umct driver supports the following adapters:
o Belkin F5U109
o Belkin F5U409
o D-Link DU-H3SP USB BAY Hub
o Magic Control Technology USB-232
o Sitecom USB-232
SEE ALSO
tty(4), ucom(4), usb(4)
HISTORY
The umct driver appeared in FreeBSD 5.2. It is loosely based on the ubsa(4) driver by Alexander Kabaev <kan@FreeBSD.org> with documentation
from Wolfgang Grandeggar <wolfgang@cec.ch>.
AUTHORS
The umct driver was written by Scott Long <scottl@FreeBSD.org>.
BSD
November 22, 2006 BSD