Sponsored Content
Full Discussion: Sum the total based on ID
Top Forums UNIX for Beginners Questions & Answers Sum the total based on ID Post 303014915 by arunkumar_mca on Friday 23rd of March 2018 10:12:27 AM
Old 03-23-2018
Sum the total based on ID

Hi

I am having a set of files which will have the card details and the amount that was spending on the card. Each file will have the set of cards and dollar amount spend on it. I am trying to sum the dollar values by card number on each files. Is there a way I do it all in all one steps
Code:
File 1:
4040011001;1;293;;;;;;;5450858.41;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011001;2;293;;;;;;;2244585.18;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011002;1;293;;;;;;;12117.55;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;1;293;;;;;;;650117.79;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;2;293;;;;;;;282250.40;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;3;293;;;;;;;34665.34;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;5;293;;;;;;;174916.29;;;;;;;;;;;;;;;;;;;;;;;;;;
File 2
4040011001;1;293;;;;;;;800990858.41;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011001;2;293;;;;;;;228999585.18;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011002;1;293;;;;;;;121232.05;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;1;293;;;;;;;650232.79;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;2;293;;;;;;;2822232.00;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;3;293;;;;;;;34.34;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;5;293;;;;;;;14916.93;;;;;;;;;;;;;;;;;;;;;;;;;;

I will be having file file1,file2,file3 and upto 126 in the directory.


Output I want is sum the card and the dollars like below
Code:
4040011001 --   1037685887
 (5450858.41 +2244585.18+800990858.41+228999585.18).
also for 4040011002,4040011003

Things I tried.

Code:
 grep ^4040011001 file1 | cut -d  -f10 | paste -sd+ | bc

This will give me the individual sum. I want to calculate all card id with out doing a individual grep
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sum total by column

Hi, i have a file which content the following: >cat cols data a:23:data data b:76:data data c:-30:data i would like to sum up the value of column 2, but the result that return to me is 0. Can anyone help? i'm using this code to do the sum awk -F" " 'BEGIN {x=0} {x+=$2} END {print... (5 Replies)
Discussion started by: thh
5 Replies

2. Shell Programming and Scripting

Calculate total sum from a file

The file content is dynamic and using this format: name1 number1 name2 number2 name3 number3 name4 number4 .................... Need a smooth way to calculate the sum of all the numbers in that file (number1 + number2 + number3 + number4........ = total ) (11 Replies)
Discussion started by: TehOne
11 Replies

3. Shell Programming and Scripting

Help with calculate total sum of same data problem

Long list of input file: AGDRE1 0.1005449050 AGDRE1 2.1005443435 AGDRE1 1.2005449050 AGDRE1 5.1005487870 AASFV3 50.456304789 AASFV3 2.3659706549 AASFV3 6.3489807860 AASFV3 3.0089890148 RTRTRS 5.6546403546 . . Desired output file: AGDRE1 8.5021829410 AASFV3 62.180245240... (2 Replies)
Discussion started by: perl_beginner
2 Replies

4. Shell Programming and Scripting

Help with total up based on same column info

Input file data US 100.25 data ENG 235.01 data US 23.12 data ENG 23.01 END UK 230.50 END Russia 20.00 . . Desired output data US 123.37 data ENG 258.02 END UK 230.50 END Russia 20.00 . . (1 Reply)
Discussion started by: perl_beginner
1 Replies

5. Shell Programming and Scripting

Help with sum total number of record and total number of record problem asking

Input file SFSQW 5192.56 HNRNPK 611.486 QEQW 1202.15 ASDR 568.627 QWET 6382.11 SFSQW 4386.3 HNRNPK 100 SFSQW 500 Desired output file SFSQW 10078.86 3 QWET 6382.11 1 QEQW 1202.15 1 HNRNPK 711.49 2 ASDR 568.63 1 The way I tried: (2 Replies)
Discussion started by: patrick87
2 Replies

6. UNIX for Dummies Questions & Answers

sum values based on ID

Hi, I would like to be able to sum up the counts of a column by the ID of another column. Example (although the actual file I have has thousands of IDs): Input file: A1BG-AS1:001 3 A1BG-AS1:002 0 A1BG-AS1:003 2 A1CF:001 1038 A1CF:002 105 A1CF:003 115 A1CF:004 137 Desired output... (3 Replies)
Discussion started by: fadista
3 Replies

7. Shell Programming and Scripting

Why sum of recs in awk don't match total rec count?

I'm using awk to determine if a field starting in position 604 for length of 10 is not equal to ALL spaces. It's searching several files which are in the current directory. The below awk indicates that there are 84 records on all files where this field IS NOT equal to ALL spaces ( there are 10... (2 Replies)
Discussion started by: mjf
2 Replies

8. UNIX for Dummies Questions & Answers

Sum based on column 1

i have file input aaa ccc,45567,rterw,1 bbb dcs,564543,hjghgh,1 aaa ccc,454,rterw,6 i want to sum based on column 1 expected output aaa ccc,7 bbb dcs,1 (4 Replies)
Discussion started by: radius
4 Replies

9. UNIX for Dummies Questions & Answers

Sum based on certain column

I have file 1 1/1/2013 A 553.0763397 96 16582 X1 X3 X5 X7 X9 1/1/2013 B 600.8333588 195 11992 X2 X3 X6 X7 X9 1/1/2013 B 459.8333588 195 11992 X1 X3 X6 X7 X9 1/2/2013 A 844.2973022 306 19555 X1 ... (12 Replies)
Discussion started by: radius
12 Replies

10. Shell Programming and Scripting

Help with calculate the total sum of record in column one

Input file: 101M 10M10D20M1I70M 10M10D39M4I48M 10M10D91M 10M10I13M2I7M1I58M 10M10I15M1D66M Output file: 101M 101 0 0 10M10D20M1I70M 100 1 10 10M10D39M4I48M 97 4 10 10M10D91M 101 0 10 10M10I13M2I7M1I58M 88 13 0 10M10I15M1D66M 91 10 1 I'm interested to count how many total of... (6 Replies)
Discussion started by: perl_beginner
6 Replies
vga_setchipset(3)						Svgalib User Manual						 vga_setchipset(3)

NAME
vga_setchipset - force chipset SYNOPSIS
#include <vga.h> void vga_setchipset(int chipset); DESCRIPTION
Force detection of a chipset (when chipset detection fails). vga_setchipset(VGA) can be useful if the chipset specific stuff or the SVGA detection stuff gives problems. However, at first the automatic detection should work well, and if not a specific chipset can be forced from /etc/vga/libvga.config. Because of that, void vga_setchipset(int chipset) should probably never be used by applications. If used nevertheless, it should be called directly before vga_init(3). As of now the following values are defined for chipset: UNDEFINED This is the default and specifies autodetection. VGA A plain VGA card, not that the SVGA must behave like an ordinary SVGA card then which will probably mean it is in an ordinary (25x80) textmode. ET4000 Tseng ET4000/ET4000W32(i/p) cards. CIRRUS Cirrus Logic GD542x/3x cards. TVGA8900 Trident TVGA 8900C/9000 (and possibly also 8800CS/8900A/B) cards. OAK Oak Technologies OTI-037/67/77/87 cards. EGA An ordinary EGA card. The notes about VGA apply. S3 An S3 base card. ET3000 Tseng ET3000 cards. MACH32 A card (from ATI or not) based on the ATI Mach32 chipset. GVGA6400 A Genoa(?) GVGA6400 card. ARK ARK Logic ARK1000PV/2000PV cards. ATI An ATI SVGA (VGA Wonder and friends) card. This does not (necessarily) include the newer cards (usually called Mach something). ALI An ALI2301 based card. MACH64 A card using the ATI Mach64 chipset. Support is not complete. CHIPS Chips and Technologies chipsets 65525, 65535, 65546, 65548, 65550, and 65554 (usually in laptops). SEE ALSO
svgalib(7), vgagl(7), libvga.config(5), vgatest(6), vga_getcurrentchipset(3), vga_setchipsetandfeatures(3) AUTHOR
This manual page was edited by Michael Weller <eowmob@exp-math.uni-essen.de>. The exact source of the referenced function as well as of the original documentation is unknown. It is very likely that both are at least to some extent are due to Harm Hanemaayer <H.Hanemaayer@inter.nl.net>. Occasionally this might be wrong. I hereby asked to be excused by the original author and will happily accept any additions or corrections to this first version of the svgalib manual. Svgalib (>;= 1.2.11) 27 July 1997 vga_setchipset(3)
All times are GMT -4. The time now is 01:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy