Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Want the UNIX code - I want to sum of the 1st column wherever the first 2nd and 3rd columns r equal Post 302930019 by Mahen on Monday 29th of December 2014 04:14:03 PM
Old 12-29-2014
Want the UNIX code - I want to sum of the 1st column wherever the first 2nd and 3rd columns r equal

I have the code for the below things..
File1 has the content as below
Code:
8859 0 subscriberCreate
18 0 subscriberPaymentMethodChange
1650 0 subscriberProfileUpdate
7668 0 subscriberStatusChange
13 4020100 subscriberProfileUpdate
1 4020129 subscriberStatusChange
2 4020307 subscriberCreate
8831 0 subscriberCreate
14 0 subscriberPaymentMethodChange
1570 0 subscriberProfileUpdate
7878 0 subscriberStatusChange
12 4020100 subscriberProfileUpdate
1 4020129 subscriberStatusChange


I want to sum of the 1st column wherever the 2nd and 3rd columns are equal.
I want the output just like below, Like sum up the 1st and column wherever 2nd and 3rd columns are equal, then print the sum,2nd and 3rd column
Code:
17690 0 subscriberCreate
32 0 subscriberPaymentMethodChange
3220 0 subscriberProfileUpdate
15546 0 subscriberStatusChange
25 4020100 subscriberProfileUpdate
2 4020129 subscriberStatusChange
2 4020307 subscriberCreate


Last edited by vgersh99; 12-29-2014 at 05:27 PM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help sum columns by break in first column with awk or sed or something.

I have some data that is something like this? item: onhand counted location ITEM0001 1 0 a1 ITEM0001 0 1 a2 ITEM0002 5 0 b5 ITEM0002 0 6 c1 I want to sum up... (6 Replies)
Discussion started by: syadnom
6 Replies

2. Shell Programming and Scripting

sum multiple columns based on column value

i have a file - it will be in sorted order on column 1 abc 0 1 abc 2 3 abc 3 5 def 1 7 def 0 1 -------- i'd like (awk maybe?) to get the results (any ideas)??? abc 5 9 def 1 8 (2 Replies)
Discussion started by: jjoe
2 Replies

3. Shell Programming and Scripting

grep data on 2nd line and 3rd column

How do I grep/check the on-hand value on the second line of show_prod script below? In this case it's a "3". So if it's > 0, then run_this, otherwise, quit. > ./show_prod Product Status Onhand Price shoe OK 3 1.1 (6 Replies)
Discussion started by: joker_789us
6 Replies

4. Shell Programming and Scripting

split on the basis of 2nd and 3rd column

file A aa 22 48 ab 22 48 tcf 50 76 gf 50 76 h 89 100 yh 89 100 how can we split the file on the basis of common 2 and third column output like file A-1 aa 22 48 ab 22 48 file A-2 cf 50 76 gf 50 76 (3 Replies)
Discussion started by: cdfd123
3 Replies

5. Shell Programming and Scripting

1st column,2nd column on first line 3rd,4th on second line ect...

I need to take one column of data and put it into the following format: 1st line,2nd line 3rd line,4th line 5th line,6th line ... Thanks! (6 Replies)
Discussion started by: batcho
6 Replies

6. Shell Programming and Scripting

Sum column values based in common identifier in 1st column.

Hi, I have a table to be imported for R as matrix or data.frame but I first need to edit it because I've got several lines with the same identifier (1st column), so I want to sum the each column (2nd -nth) of each identifier (1st column) The input is for example, after sorted: K00001 1 1 4 3... (8 Replies)
Discussion started by: sargotrons
8 Replies

7. Linux

Print the 1st column and the value in 2nd or 3rd column if that is different from the values in 1st

I have file that looks like this, DIP-17571N|refseq:NP_651151 DIP-17460N|refseq:NP_511165|uniprotkb:P45890 DIP-17571N|refseq:NP_651151 DIP-19241N|refseq:NP_524261 DIP-19241N|refseq:NP_524261 DIP-17151N|refseq:NP_524316|uniprotkb:O16797 DIP-19588N|refseq:NP_731165 ... (2 Replies)
Discussion started by: Syeda Sumayya
2 Replies

8. Shell Programming and Scripting

Sum of Columns Base on First Column

Input :- Hd1;Hd2:hd3;Hd4;Hd5 X;1;2;3;4 Y;2;3;5;6 Z;3;5;6;7 X;10;11;24;16 Y;11;23;21;1 Z;10;13;14;15 X;0;1;2;0 K;0;0;0;0 K;0;0;0;0 I want Sum Data base on first column; Hd1;Hd2:hd3;Hd4;Hd5 X;11;14;29;20 Y;12;26;26;7 Z;13;18;20;22 K;0;0;0;0 (4 Replies)
Discussion started by: pareshkp
4 Replies

9. Shell Programming and Scripting

awk to Sum columns when other column has duplicates and append one column value to another with Care

Hi Experts, Please bear with me, i need help I am learning AWk and stuck up in one issue. First point : I want to sum up column value for column 7, 9, 11,13 and column15 if rows in column 5 are duplicates.No action to be taken for rows where value in column 5 is unique. Second point : For... (1 Reply)
Discussion started by: as7951
1 Replies

10. 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
mdbGeneral(5)							 The m17n Library						     mdbGeneral(5)

NAME
mdbGeneral - General Format DESCRIPTION
The mdatabase_load() function returns the data specified by tags in the form of plist if the first tag is not Mchartable nor Mcharset. The keys of the returned plist are limited to Minteger, Msymbol, Mtext, and Mplist. The type of the value is unambiguously determined by the corresponding key. If the key is Minteger, the value is an integer. If the key is Msymbol, the value is a symbol. And so on. A number of expressions are possible to represent a plist. For instance, we can use the form (K1:V1, K2:V2, ..., Kn:Vn) to represent a plist whose first property key and value are K1 and V1, second key and value are K2 and V2, and so on. However, we can use a simpler expression here because the types of plists used in the m17n database are fairly restricted. Hereafter, we use an expression, which is similar to S-expression, to represent a plist. (Actually, the default database loader of the m17n library is designed to read data files written in this expression.) The expression consists of one or more elements. Each element represents a property, i.e. a single element of a plist. Elements are separated by one or more whitespaces, i.e. a space (code 32), a tab (code 9), or a newline (code 10). Comments begin with a semicolon (;) and extend to the end of the line. The key and the value of each property are determined based on the type of the element as explained below. o INTEGER An element that matches the regular expression -?[0-9]+ or 0[xX][0-9A-Fa-f]+ represents a property whose key is Minteger. An element matching the former expression is interpreted as an integer in decimal notation, and one matching the latter is interpreted as an integer in hexadecimal notation. The value of the property is the result of interpretation. For instance, the element 0xA0 represents a property whose value is 160 in decimal. o SYMBOL An element that matches the regular expression [^-0-9(]([^()]|.)+ represents a property whose key is Msymbol. In the element, , , , and e are replaced with tab (code 9), newline (code 10), carriage return (code 13), and escape (code 27) respectively. Other characters following a backslash is interpreted as it is. The value of the property is the symbol having the resulting string as its name. For instance, the element abc def represents a property whose value is the symbol having the name 'abc def'. o MTEXT An element that matches the regular expression '([^']|')*' represents a property whose key is Mtext. The backslash escape explained above also applies here. r, each part in the element matching the regular expression [xX][0-9A-Fa-f][0-9A-Fa-f] is replaced with its hexadecimal interpretation. After having resolved the backslash escapes, the byte sequence between the double quotes is interpreted as a UTF-8 sequence and decoded into an M-text. This M-text is the value of the property. o PLIST Zero or more elements surrounded by a pair of parentheses represent a property whose key is Mplist. Whitespaces before and after a parenthesis can be omitted. The value of the property is a plist, which is the result of recursive interpretation of the elements between the parentheses. SYNTAX NOTATION
In an explanation of a plist format of data, a BNF-like notation is used. In the notation, non-terminals are represented by a string of uppercase letters (including '-' in the middle), terminals are represented by a string surrounded by '"'. Special non-terminals INTEGER, SYMBOL, MTEXT and PLIST represents property integer, symbol, M-text, or plist respectively. EXAMPLE
Here is an example of database data that is read into a plist of this simple format: DATA-FORMAT ::= [ INTEGER | SYMBOL | MTEXT | FUNC ] * FUNC ::= '(' FUNC-NAME FUNC-ARG * ')' FUNC-NAME ::= SYMBOL FUNC-ARG ::= INTEGER | SYMBOL | MTEXT | '(' FUNC-ARG ')' For instance, a data file that contains this text matches the above syntax: abc 123 (pqr 0xff) "m and is read into this plist: 1st element: key: Msymbol, value: abc 2nd element: key: Minteger, value: 123 3rd element: key: Mplist, value: a plist of these elements: 1st element: key Msymbol, value: pgr 2nd element: key Minteger, value: 255 4th element: key: Mtext, value: m"text 5th element: key: Mplist, value: a plist of these elements: 1st element: key: Msymbol, value: __ 2nd element: key: Mplist, value: a plist of these elements: 1st element: key: Mtext, value: string 2nd element: key: Msymbol, value: xyz 3rd element: key: Minteger, value: -456 COPYRIGHT
Copyright (C) 2001 Information-technology Promotion Agency (IPA) Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST) Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>. Version 1.6.2 12 Jan 2011 mdbGeneral(5)
All times are GMT -4. The time now is 02:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy