Sponsored Content
Top Forums Shell Programming and Scripting Get the total of a field in all the lines of a group Post 302253452 by appsguy616 on Friday 31st of October 2008 03:36:20 PM
Old 10-31-2008
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"
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

total number of lines

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)
Discussion started by: mahabunta
4 Replies

2. Shell Programming and Scripting

Awk-Group count of field

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)
Discussion started by: tinivt
5 Replies

3. Shell Programming and Scripting

need to delete all lines from a group of files except the 1st 2 lines

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)
Discussion started by: script_op2a
3 Replies

4. Shell Programming and Scripting

Adding total of first field for each number in the second field

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)
Discussion started by: shary
2 Replies

5. Shell Programming and Scripting

Select lines in which column have value greater than some percent of total file lines

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)
Discussion started by: vaibhavkorde
6 Replies

6. Shell Programming and Scripting

Transpose, Group, and Total

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)
Discussion started by: ravzter
3 Replies

7. Shell Programming and Scripting

awk repeat one field at all lines and modify field repetitions

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)
Discussion started by: phaethon
2 Replies

8. Shell Programming and Scripting

How to add subtotal and total according 3rd field mentioned below table?

111AKKK|SHA|20|25 111|AKKK|SHA|15|35 112|ABC|FL|25|45 112|ABC|FL|15|15 115|AKKK|ASH|10|15 115|AKKK|ASH|20|20 112|ABC|FL|25|20 115|AKKK|ASH|30|35 111|AKKK|SHA|10|45 112|ABC|KL|15|15 112|ABC|KL|20|25 115|AKKK|ASH|30|35 please write a shell script output should be below mentioned... (26 Replies)
Discussion started by: udhal
26 Replies

9. Shell Programming and Scripting

Calculate the total 4 field based on the conditions

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)
Discussion started by: kalia4u
22 Replies

10. Shell Programming and Scripting

awk to calculate total and percent off field in file

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)
Discussion started by: cmccabe
4 Replies
FILECHAN(8)						      System Manager's Manual						       FILECHAN(8)

NAME
filechan - file-writing backend for InterNetNews SYNOPSIS
filechan [ -d directory ] [ -f fields ] [ -m mapfile ] [ -p pidfile ] DESCRIPTION
Filechan reads lines from standard input and copies certain fields in each line into files named by other fields within the line. Filechan is intended to be called by innd(8) as a channel feed. (It is not a full exploder and does not accept commands; see newsfeeds(5) for a description of the difference and buffchan(8) for an exploder program.) Filechan input is interpreted as a set of lines. Each line contains a fixed number of initial fields, followed by a variable number of filename fields. All fields in a line are separated by whitespace. The default number of initial fields is one. For each line of input, filechan writes the initial fields, separated by whitespace and followed by a newline, to each of the files named in the filename fields. When writing to a file, filechan opens it in append mode and tries to lock it and change the ownership to the user and group who owns the directory where the file is being written. OPTIONS
-f The ``-f'' flag may be used to specify a different number of fields. -d By default, filechan writes its arguments into the directory /var/spool/news/out.going. The ``-d'' flag may be used to specify a directory the program should change to before starting. -p If the ``-p'' flag is used, the program will write a line containing its process ID (in text) to the specified file. If filechan is invoked with ``-f 2'' and given the following input: news/software/b/132 <1643@munnari.oz.au> foo uunet news/software/b/133 <102060@litchi.foo.com> uunet munnari comp/sources/unix/2002 <999@news.foo.com> foo uunet munnari Then the file foo will have these lines: news/software/b/132 <1643@munnari.oz.au> comp/sources/unix/2002 <999@news.foo.com> the file munnari will have these lines: news/software/b/133 <102060@litchi.foo.com> comp/sources/unix/2002 <999@news.foo.com> and the file uunet will have these lines: news/software/b/132 <1643@munnari.oz.au> news/software/b/133 <102060@litchi.foo.com> comp/sources/unix/2002 <999@news.foo.com> Because the time window in which a file is open is very small, complicated flushing and locking protocols are not needed; a mv(1) followed by a sleep(1) for a couple of seconds is sufficient. -m A map file may be specified by using the ``-m'' flag. Blank lines and lines starting with a number sign (``#'') are ignored. All other lines should have two host names separated by a colon. The first field is the name that may appear in the input stream; the second field names the file to be used when the name in the first field appears. For example, the following map file may be used to map the short names above to the full domain names: # This is a comment uunet:news.uu.net foo:foo.com munnari:munnari.oz.au HISTORY
Written by Robert Elz <kre@munnari.oz.au>, flags added by Rich $alz <rsalz@uunet.uu.net>. This is revision 1.19, dated 1996/10/29. SEE ALSO
buffchan(8), innd(8), newsfeeds(5). FILECHAN(8)
All times are GMT -4. The time now is 02:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy