Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Okay, I think I am almost done. Just to let you guys know, I have found a lot of things on my own...
I would like to give data totals for a given week from Sunday to Saturday. Most of the questions I asked I had somewhat of a start on before I asked (not necerally anywhere close to the end answer). I am totally clueless on this one.
03/16/2003 10355.2
03/17/2003 10770.9
03/18/2003 9259.4
03/19/2003 8131.2
03/20/2003 8914.6
03/21/2003 10473.9
03/22/2003 12896.2
03/23/2003 11312.6
03/24/2003 11207.6
03/25/2003 9841.2
03/26/2003 8470.0
03/27/2003 10481.5
03/28/2003 12226.4
03/29/2003 15764.8This is what I want...
Week ending 03/22/2003 70801.4
week ending 03/29/2003 79304.1

Robert:
Totally brute force:
#!/usr/bin/ksh
awk ' BEGIN { total=0 }
{
total+=$2
if ($1 == "03/22/2003" || $1 == "03/29/2003")
{
printf("Week ending %s is: %.2f\n", $1, total)
total=0
}
} ' data.file
# end awk scriptRegards,
Nails

hai,
i read ur question. very interesting programming question. but i can't understand fully. wad my doubt was whether v have to generalise the code, or i have to find sum from 16th to 22nd and 23rd to 29th. plz explain me the question breifly.byee
kannanvijay

Yes, I am looking for a sum of the 2nd column.
The script nails gave me works, but it gives a sum for the first one of everything before it. Is there a way to tell it to go back only 7 days?
Is there a way to have it automatically figure out the dates?
Thanks for what you have given me so far.
Robert

![]() |
SED using special charact...
|
Please help! Variables
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |