Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how to count number of rows and sum of column using awk Post 302422525 by pistachio on Tuesday 18th of May 2010 04:11:49 PM
Old 05-18-2010
how to count number of rows and sum of column using awk

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
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to sum rows in e.g. column 1 by a category in e.g. column 2

Hi, I've shown an example of what I would like to achieve below. In the example file, I would like to sum the values in column 2 for each distinct category in column 3 (presumably making an array?) and print the sum as well as the category name and length (note:length always corresponds with... (8 Replies)
Discussion started by: auburn
8 Replies

2. Shell Programming and Scripting

awk count characters, sum, and divide by another column

Hi All, I am another biologist attempting to parse a large txt file containing several million lines like: tucosnp 56762 T Y 228 228 60 23 .CcCcc,,..c.c,cc,,.C... What I need to do is get the frequency of periods (.) plus commas (,) in column 9, and populate this number into another... (1 Reply)
Discussion started by: peromhc
1 Replies

3. Shell Programming and Scripting

how to add the number of row and count number of rows

Hi experts a have a very large file and I need to add two columns: the first one numbering the incidence of records and the another with the total count The input file: 21 2341 A 21 2341 A 21 2341 A 21 2341 C 21 2341 C 21 2341 C 21 2341 C 21 4567 A 21 4567 A 21 4567 C ... (6 Replies)
Discussion started by: juelillo
6 Replies

4. UNIX for Dummies Questions & Answers

count number of rows based on other column values

Could anybody help with this? I have input below ..... david,39 david,39 emelie,40 clarissa,22 bob,42 bob,42 tim,32 bob,39 david,38 emelie,47 what i want to do is count how many names there are with different ages, so output would be like this .... david,2 emelie,2 clarissa,1... (3 Replies)
Discussion started by: itsme999
3 Replies

5. UNIX for Dummies Questions & Answers

Sum the rows number based on first field string value

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

6. UNIX for Dummies Questions & Answers

count number of distinct values in each column with awk

Hi ! input: A|B|C|D A|F|C|E A|B|I|C A|T|I|B As the title of the thread says, I would need to get: 1|3|2|4 I tried different variants of this command, but I don't manage to obtain what I need: gawk 'BEGIN{FS=OFS="|"}{for(i=1; i<=NF; i++) a++} END {for (b in a) print b}' input ... (2 Replies)
Discussion started by: beca123456
2 Replies

7. Shell Programming and Scripting

awk code to ignore the first occurence unknown number of rows in a data column

Hello experts, Shown below is the 2 column sample data(there are many data columns in actual input file), Key, Data A, 1 A, 2 A, 2 A, 3 A, 1 A, 1 A, 1 I need the below output. Key, Data A, 2 A, 2 A, 3 A, 1 A, 1 A, 1 (2 Replies)
Discussion started by: ks_reddy
2 Replies

8. UNIX for Dummies Questions & Answers

Script to count number of rows

Hi, I need a solaris shell script to read multiple files and count number of unique name rows(strings) from those files. The input and output should be like this Input: file 1 abc cde abc ... (9 Replies)
Discussion started by: ssk250
9 Replies

9. UNIX for Beginners Questions & Answers

Copy columns from one file into another and get sum of column values and row count

I have a file abc.csv, from which I need column 24(PurchaseOrder_TotalCost) to get the sum_of_amounts with date and row count into another file say output.csv abc.csv- UTF-8,,,,,,,,,,,,,,,,,,,,,,,,, ... (6 Replies)
Discussion started by: Tahir_M
6 Replies

10. Shell Programming and Scripting

Count Repetitive Number in a column and renumbering using awk

Unable to get the desired output. Need only the rows which has repeated values in column 5. Input File <tab separated file> chr1 3773797 3773797 CEP10 1 chr1 3773797 3773797 CEP104 2 chr1 3689350 3689350 SMIM1 2 chr1 3773797 3773797 CEP4 3 chr1 3773797 3773797 EP104 ... (7 Replies)
Discussion started by: himanshu
7 Replies
CM(4)							   BSD Kernel Interfaces Manual 						     CM(4)

NAME
cm -- SMC Arcnet Ethernet device driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device isa device cm Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): if_cm_load="YES" DESCRIPTION
The cm driver provides support for the Arcnet ISA network adapters. This driver also has quirks preset in the device.hints(5) file for card detection. HARDWARE
The cm driver supports the following card models: o SMC90c26 o SMC90c56 o SMC90c66 in '56 compatibility mode. IMPLEMENTATION NOTES
When the NOARP flag is set on the cm interface, it does not employ the address resolution protocol described in arp(4) to dynamically map between Internet and Ethernet addresses on the local network. Instead it uses the least significant 8 bits of the IP address as the hardware address like described in RFC 1051 and RFC 1201. With the IFF_LINK0 flag cleared IP/ARP/RARP encoding is done according to RFC 1201 that is, with Packet Header Definition Standard header and packet type 212 / 213. The MTU is normally 1500. The IFF_LINK0 flag is cleared by default. With the IFF_LINK0 flag set, IP and ARP encoding is done according to the deprecated RFC 1051 encoding, that is with simple header, packet type 240 / 241, and the MTU is 507. When switching between the two modes, use ifconfig interfacename down up to switch the MTU. DIAGNOSTICS
The following driver specific error messages may be reported: reset: card reset, link addr = 0x%02x (cm%d) The card is being reset and a new link address assigned. srint: restarted rx on buf cm%d The rx buffer has been emptied and will be reset. SEE ALSO
netintro(4), watchdog(4), device.hints(5), ifconfig(8), watchdog(8) HISTORY
The cm device was ported from NetBSD by Max Khon <fjoe@FreeBSD.org> and first appeared in FreeBSD 4.6. This manual page first appeared in FreeBSD 5.3. AUTHORS
This manual page was written by Tom Rhodes <trhodes@FreeBSD.org>. The IMPLEMENTATION NOTES section was submitted by Max Khon <fjoe@FreeBSD.org> and originated from NetBSD. BUGS
The cm driver code could do with a bit of improvement, it would be nice if some one could come along and take care of this. The IMPLEMENTATION NOTES section is specific to all Arcnet devices (see sys/net/if_arcsubr.c) and should be moved to a more generic location. BSD
July 16, 2005 BSD
All times are GMT -4. The time now is 03:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy