LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-26-2014, 07:19 PM   #1
master-of-puppets
Member
 
Registered: Jun 2011
Posts: 49

Rep: Reputation: Disabled
awk sum printf


I have to fix some output files by skipping the first three lines and then adding the used+avaliable (which are columns 2+3) and then printing back out the results for the second column after the date column and then printing used for the third column.

In other words right now you're supposed to be seeing:
Code:
date,size,used,size,used,size,used,etc....
But you are really seeing:
Code:
date,size,available,size,available,size,available,etc....
Code:
,
simpsons
,bart_size,bart_used,homer_size,home_used,lisa_size,lisa_used,marge_size,marge_used,releases_size,releases_used,rt-private_size,rt-private_used,simpsons-ws0_size,simpsons-ws0_used,simpsons-ws1_size,simpsons-ws1_used,simpsons-ws2_size,simpsons-ws2_used,vsimpsons-ws_size,vsimpsons-ws_used
09-25-14,1169146,28530,1176105,21571,1195531,2145,162603,2947,312411,97140,991943,967446,163460,5461,1014543,9389,221737,757958,23931,12728
09-26-14,1158376,39300,1164327,33349,1135692,61984,160432,5118,318347,91205,991872,967517,163048,5873,1020307,3625,212295,767401,22666,13993
09-27-14,1151044,46632,1172183,25493,1141420,56256,160432,5118,357359,52192,991945,967444,162769,6151,1021095,2837,226565,753131,30659,6000
09-28-14,1156765,40911,1172185,25490,1141854,55822,160432,5118,357372,52179,991945,967444,162769,6151,1021063,2869,226566,753130,23979,12681
09-29-14,1166987,30689,1158635,39041,1142596,55080,160433,5117,357372,52179,991946,967444,162699,6222,1021454,2478,247473,732223,23131,13528
09-30-14,1164142,33534,1153434,44242,1142975,54701,160433,5117,315138,94413,979826,979563,163108,5813,1021495,2437,258712,720983,23843,12816
10-01-14,1141073,56603,1128764,68912,1147895,49781,160433,5117,287244,122307,1036897,922492,163135,5786,1018990,4942,262935,716761,24333,12327
10-03-14,1007020,190656,1143694,53981,1144079,53597,160366,5184,287099,122452,1037051,922338,167316,1604,1023693,239,273334,706361,26257,10403
10-04-14,1015788,181888,1149441,48235,1151340,46336,160367,5184,319840,89711,1037148,922241,167363,1558,1022109,1823,299049,680646,26872,9788
10-05-14,1015742,181934,1149449,48227,1151485,46191,160367,5183,319840,89711,1037148,922241,167363,1557,1022129,1803,299085,680610,38621,0
10-06-14,1019788,177888,1149860,47816,1151449,46227,160367,5183,319912,89639,1037149,922241,164664,4257,1022125,1807,304125,675571,33702,2958
10-07-14,971901,225775,857518,340158,1154555,43121,102871,62679,236794,172757,1164663,794726,168920,0,1019462,4471,326128,653567,22545,14114
10-08-14,742589,455087,855562,342114,776976,420699,102872,62678,236793,172758,1164664,794726,120569,48352,664791,359141,345230,634465,23401,13258
10-09-14,754477,443199,870359,327317,785946,411730,102872,62678,236794,172757,1164664,794725,117875,51046,664460,359473,353439,626257,23935,12725
10-10-14,767956,429720,878716,318960,763838,433838,102873,62678,301916,107635,1164812,794577,116950,51971,664428,359504,364645,615050,23124,13536
10-11-14,785192,412484,902116,295560,763803,433873,102873,62677,326735,82816,1165017,794372,118833,50088,663313,360619,370561,609135,23136,13524
10-12-14,785302,412374,902186,295490,767149,430527,102873,62677,253394,156157,1239314,720076,118836,50084,663317,360615,373795,605900,23159,13500
10-13-14,785476,412200,908251,289425,773820,423856,102874,62677,261734,147818,1239326,720063,118710,50211,664193,359739,378826,600869,23146,13514
10-14-14,785370,412306,897102,300574,783108,414568,102874,62676,267595,141956,1239407,719983,121380,47541,679145,344788,407709,571986,33426,3233
10-15-14,779481,418195,903504,294172,787041,410635,102874,62676,284796,124755,1239415,719974,121380,47541,692608,331324,413171,566525,23296,13364
10-16-14,770403,427273,912933,284743,790104,407572,102874,62676,328830,80721,1243226,716164,121440,47481,702225,321707,423333,556363,25471,11188
10-17-14,787711,409965,897294,300382,799999,397677,102875,62676,257732,151819,1220034,739355,120962,47958,705158,318775,445272,534423,35921,738
10-18-14,805996,391680,897494,300182,802631,395045,102875,62675,307139,102412,1220185,739205,121262,47659,711301,312631,451536,528159,23606,13053
10-19-14,806009,391667,897972,299704,802785,394891,102875,62675,307140,102411,1220185,739204,121292,47629,711302,312630,451571,528124,23591,13068
10-20-14,805002,392674,895483,302193,802652,395024,102876,62675,307140,102411,1220185,739204,121292,47628,714831,309101,455254,524441,23559,13100
10-21-14,811788,385888,904695,292981,803639,394037,102876,62674,244710,164841,1255419,703971,121293,47628,714739,309193,462564,517132,23575,13085
10-22-14,781994,415682,912996,284680,805875,391800,102876,62674,253368,156183,1118647,840743,123222,45699,714545,309388,472638,507057,23652,13007
10-23-14,799104,398572,907791,289884,800812,396864,102921,62629,266966,142585,1170245,789145,127269,41652,717743,306189,462132,517564,23744,12915
10-24-14,822788,374888,907632,290044,809349,388327,102921,62629,309108,100443,1170387,789003,126926,41994,720110,303822,475233,504462,23662,12998
10-25-14,842453,355223,913967,283709,805917,391759,102922,62629,275189,134362,1239399,719990,133611,35309,731400,292532,485589,494106,23735,12925
10-26-14,816319,381357,854186,343490,781099,416577,102196,63355,275260,134291,1239423,719967,133612,35308,691805,332127,485744,493951,25315,11344
 
Old 10-27-2014, 01:59 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
So I see input, but not any attempt to solve? This is not your first time asking a question and you know everyone will only reply with ...'We will not do the work for you'

So, show us what you have tried and where you are stuck?
 
1 members found this post helpful.
Old 10-27-2014, 02:10 AM   #3
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
tail +4 file3 | cut -f2,3 -d "," | tr "," '+' |bc
you can try adding up the total yourself
 
Old 10-27-2014, 03:17 PM   #4
master-of-puppets
Member
 
Registered: Jun 2011
Posts: 49

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by grail View Post
So I see input, but not any attempt to solve? This is not your first time asking a question and you know everyone will only reply with ...'We will not do the work for you'

So, show us what you have tried and where you are stuck?
I do have some code I figured something out on my own.
 
Old 10-28-2014, 08:59 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
And so, are you going to share said solution, so others might learn from you
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
weird awk output while trying to sum a field schneidz Programming 5 06-26-2012 11:29 PM
sum up values from each columns (awk) lcvs Linux - Newbie 10 06-20-2012 04:16 AM
Help with Awk and Printf, please! romeo0307 Linux - Newbie 16 05-08-2012 02:30 PM
awk's sum not working? grob115 Linux - Newbie 4 04-29-2010 12:44 PM
[SOLVED] awk - sum total if field = string schneidz Programming 12 03-20-2010 04:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration