Get the total of a field in all the lines of a group
Hi
I have a Fixed format data file where I need to to get the total of the field at certain position in a file for a group of lines.
In this data file I need the total of all the field ats position 30:39 for each line starting with 6 and for each group startign with 5. Which means for every line starting with 5 I need the total of the fields in line 6 respecitvely. So I would get 2 totals in this case as I have two lines starting with 5.
With this script I am getting for all lines with 6 I need it to geoup by line 5.
How to do it? Please help
101 12110825030430021170810060810A094101BANK OF AMERICA
5200AMERICAN EXP 144892 3043002117CCDOCT06 2008
62201100123409-1960 000013768460000526 AMERICAN
62201100123409-1960 000085263060000526 AMERICAN
62201100123409-1960 000004188960000526 AMERICAN
62201100123409-1960 000025960260000526 AMERICAN
62201100123409-1960 000009390060000526 AMERICAN
62201100123409-1960 000028661060000526 AMERICAN
62201100123409-1960 000006656060000526 AMERICAN
62201100123409-1960 000004047360000526 AMERICAN
62201100123409-1960 000002500060000526 AMERICAN
5200AMERICAN EXP 144892 3043002117CCDOCT07 2008
62201100123409-1960 000023768460000526 AMERICAN
62201100123409-1960 000025263060000526 AMERICAN
62201100123409-1960 000024188960000526 AMERICAN
705RMR*11*379477306771000*0000133379
Hi
I want the total of the field at position 30-39 on all Lines 6 to be displayed. so Every 5 line will have only one 6 line with the total of all the lines 6
Thanks
Pls help
so the total sum of of all the values in quotes " " should be dispalyed in the first 6 line and delete remaining. similarly for the other 5 line do the same.
101 12110825030430021170810060810A094101BANK OF AMERICA
5200AMERICAN EXP 144892 3043002117CCDOCT06 2008
62201100123409-1960 "0000137684"60000526 AMERICAN
62201100123409-1960 "0000852630"60000526 AMERICAN
62201100123409-1960 "0000041889"60000526 AMERICAN
62201100123409-1960 "0000259602"60000526 AMERICAN
62201100123409-1960 "0000093900"60000526 AMERICAN
62201100123409-1960 "0000286610"60000526 AMERICAN
62201100123409-1960 "0000066560"60000526 AMERICAN
62201100123409-1960 "0000040473"60000526 AMERICAN
62201100123409-1960 "0000025000"60000526 AMERICAN
5200AMERICAN EXP 144892 3043002117CCDOCT07 2008
62201100123409-1960 000023768460000526 AMERICAN
62201100123409-1960 000025263060000526 AMERICAN
62201100123409-1960 000024188960000526 AMERICAN
705RMR*11*379477306771000*0000133379
Last edited by appsguy616; 10-31-2008 at 02:32 PM..
The required output should be. Basically I want only one line starting with 6 should appear but the field at positon 30:39 for the line should be the sum of all the fields at this position on all the lines starting with 6. But this should group by based on line starting with 5.
101 12110825030430021170810060810A094101BANK OF AMERICA
5200AMERICAN EXP 144892 3043002117CCDOCT06 2008
62201100123409-1960 "0001710448"60000526 AMERICAN
5200AMERICAN EXP 144892 3043002117CCDOCT07 2008
62201100123409-1960 "0000732203"60000526 AMERICAN
705RMR*11*379477306771000*0000133379
where "0001710448" is the total of all the fields in quotes lines starting with 6 for the first group line 5
"0000137684"
"0000852630"
"0000041889"
"0000259602"
"0000286610"
"0000066560"
"0000040473"
"0000025000"
"0001710448"
Smilarly 0000732203 is the total of all the lines starting with 6 for the second group line 5
"0000237684"
"0000252630"
"0000241889"
Trying to use awk to print the lines in file that have either REF or SNV in $3, add a header line, sort by $4 in numerical order. The below code does that already, but where I am stuck is on the last part where the total lines are counted and printed under Total_Targets, under Targets_less_than is... (4 Replies)
Please help me to write a script
Match with ACNO & NAME if it matched calculate the total val1 val2 val3 and val4 and GT is total of ACNO wise.please check the output
Table
-----------------
1005|ANDP|ACN|20|50|10|30
1005|ANDP|ACN|20|10|30|40
1001|AND|NAC|40|50|40|50... (22 Replies)
Hello experts
I have a file with paragraphs begining with a keeping date and ending with "END":
20120301 num num
John num num A keepnum1 num num
kathrin num num A keepnum1 num num
kathrin num num B keepnum2 num num
Pete num num A keepnum1 num num
Jacob num... (2 Replies)
Need help with some data below.
I would like to transpose rows of column c, h to columns with those labels(c,h.)
I would then like to sort and group by the values in columns c then h.
For column h I would like to further sort by the parenthesis values.
After the sort I would like an... (3 Replies)
i have a file in following format
1 32 3
4 6 4
4 45 1
45 4 61
54 66 4
5 65 51
56 65 1
12 32 85
now here the total number of lines are 8(they vary each time)
Now i want to select only those lines in which the values... (6 Replies)
Dears,
I need a script or command which can find the unique number from the second filed and against that number it adds the total of first field .
17215630 , 0
907043 ,1
201050 ,10
394149 ,4
1964 ,9
17215630, 0
907043 ,1
201050, 10
394149 ,4
1964 ,9
1234234, 55
23 ,100
33 ,67
... (2 Replies)
Hello,
I have a group of text files with many lines in each file.
I need to delete all the lines in each and only leave 2 lines in each file. (3 Replies)
Hi,
Suppose if i am having a file with following records as given below.
5555
6756
5555
4555
4555
6767
how can i get the count of each record using AWK.
Eg:5555 count should be 2
4555 count should be 2
6767 count should be 1
... (5 Replies)
Hi have following file
|abcd
2|abcd
|sdfh
|sdfj
I want to find total number of files haivng nothing in feild 1 using awk
will command
awk -F "|" '( $1=="") {print NR}' test_awk
will work??? (4 Replies)