Sponsored Content
Top Forums Shell Programming and Scripting First_File, Second_File and Final_File awk magic Post 302914168 by kekanap on Friday 22nd of August 2014 11:08:41 AM
Old 08-22-2014
First_File, Second_File and Final_File awk magic

Hallo Team,

I hope my explanation is clear. Please assist if you can.

max1.csv
Code:
AccountCode,AccountName,TotalCalls,TotalCallDuration,TotalCost,TotalTelkomAsIf
485554,MHG - Polmed - BLM,415,06:46:27,132.88,437.72
758495,MGH -  Polmed -  Polokwane,587,13:40:35,235.73,713.02
661178,MHG - Cape Town,238878,14210:29:27,230762.11,558658.12
668900,MHG - Polmed - Kimberly,224,03:36:33,72.23,237.76
631005,MHG - Polmed - Nelspruit,1426,38:15:09,1054.03,2695.12
822234,MHG - Pretoria,94738,7399:38:47,94198.51,273010.77
520704,MHG - Polmed - Umtata,267,13:21:46,273.79,693.19
155945,MHG- Vois - Durban,18988,999:46:49,18354.78,36190.84
781681,MHG - Polmed - DBN,486,18:29:35,516.74,1212.01
298334,MHG - Durban,121,07:13:34,65.03,220.06
146536,MHG - Polmed - PE,907,19:02:36,423.68,1266.53
563416,MHG - Braamfontein,96329,7622:36:01,106670.89,264574.65
995958,MHG - Polmed - Paarl,356,15:40:53,412.96,941.17
347012,MHG - Polmed - Mafikeng,522,13:34:18,370.33,949.97
616356,MHG - QUALSA-POLOKWANE,2,00:00:17,0,0.5

max2.csv
Code:
ContactCalls,ContactCallDuration,ContactCallCost,ContactTotalTelkomAsIf
0,00:00:00,0,0
0,00:00:00,0,0
39819,4033:46:29,36303.97,122416
0,00:00:00,0,0
0,00:00:00,0,0
60709,5875:49:54,53006.06,178499.14
0,00:00:00,0,0
0,00:00:00,0,0
0,00:00:00,0,0
121,07:13:34,65.03,221.13
0,00:00:00,0,0
9063,673:10:03,6332.19,20613.26
0,00:00:00,0,0
0,00:00:00,0,0
0,00:00:00,0,0

I would like to sum up all the values under max1 and max2
Code:
Max1_summed_up.csv
MHG - Inbound    454246    16171:43:20    453543.69    1141801.43

Code:
Max2_summed_up.csv
109712    10590:00:00    95707.25    321749.53

Now from here i would like to subtract Max2_summed_up.csv from Max1_summed_up.csv

So Final_File.csv should be as below

Code:
cat Final_File.csv
MHG - Inbound Final    344534    5581:43:20    357836.44    820051.9    0    0:00:00    0    0

I thank you in advance and regards,

Pax

Last edited by bartus11; 08-22-2014 at 12:42 PM.. Reason: Please use [code][/code] tags instead of [icode] and [quote].
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Boot Magic 7

For a multi-boot setup (win2K, XP & SuSE) over 3 drives, where should Boot Magic be installed to? And does it matter which o/s installs it? (3 Replies)
Discussion started by: onestepto
3 Replies

2. UNIX for Advanced & Expert Users

what is magic file ?

i am working under this sysytem SunOS sparc SUNW,UltraAX-i2 Some system on this server creates a file named like this. Elem_ee.xml.gz Elem_ee.xml.gz.magic In order to look into Elem_ee.xml.gz.magic, i first renamed Elem_ee.xml.gz.magic to Elem_ee.xml.gz and tried to unzip it. but returns... (3 Replies)
Discussion started by: oppai
3 Replies

3. UNIX for Dummies Questions & Answers

magic.h

Where can I find #defines for filetypes like the ELF etc and the magic.h file? CAn anyone advice. Thanks in advance. (0 Replies)
Discussion started by: vijlak
0 Replies

4. UNIX for Advanced & Expert Users

magic.h

Where can I find #defines for filetypes like the ELF etc and the magic.h file? CAn anyone advice. Thanks in advance. (1 Reply)
Discussion started by: vijlak
1 Replies

5. Shell Programming and Scripting

AWK and Magic with file parsing

Hi, I have a input file like this TH2TH2867Y NOW33332106Yo You Baby TH2TH3867Y NOW33332106No Way Out TH2TH9867Y NOW33332106Can't find it TJ2TJ2872N WOW33332017sure thing alas TJ2TJ3872N WOW33332017the sky rocks TJ2TJ4872N WOW33332017nothing else matters TJ2TJ5872N WOW33332017you know... (1 Reply)
Discussion started by: devtakh
1 Replies

6. Shell Programming and Scripting

sed magic!

Hi, I have this line in my script, and works perfect! tran= "$(sed = "$fname" | sed "/./N; s/\n/: /" | sed -n "${beg},${end}p")" $fname its a file, and gets multilines between beg and end.: Something like this: 1: line a 2: line b 3: line c But now, I want insert in the end of each... (9 Replies)
Discussion started by: vibra
9 Replies

7. UNIX for Dummies Questions & Answers

magic 8ball

when i use this code for the script of the magic 8ball, i get an error message and it always displays the sam answer. What am i doing wrong or what am i missing thanks #!/bin/sh #< Magic eight ball! # KW 26/11/04 # Requires "rand" echo "Enter \"q\" followed by return to quit" function... (6 Replies)
Discussion started by: JamieMurry
6 Replies

8. Shell Programming and Scripting

sed magic

I want to become an expert @ using sed, but i do not have enough time... Atm I have a repository in my apt/sources.list but it is commented out since i do not want to install packages from it (backtrack repository) except the exploitdb package. I would like make a command, lets say... (5 Replies)
Discussion started by: redsolja
5 Replies

9. What is on Your Mind?

I got a magic wand

My new magic wand just came. It looks great. Looking at it, it looks like it is carved by hand from a solid piece of wood. It could easily serve as a prop in a Harry Potter film. But it is actually a high tech appliance. A built-in accelerometer can detect how you are moving the wand. ... (2 Replies)
Discussion started by: Perderabo
2 Replies

10. Shell Programming and Scripting

sed magic

Hello all, I have an inherited an old ugly script I'm trying to clean up a bit. What I am currently working on is a line like the following: Complication=" and ta.secID = 011222 and upper(ta.proc_ctrl_no) != 'IMPACT'";; I just want to combine a search for lines that begin with... (5 Replies)
Discussion started by: blip42
5 Replies
All times are GMT -4. The time now is 12:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy