Hi everyone, i need help with a simple task. I have a file withe the format:
"01/20/2012 23:10:13.979","49","49","48","19"
"01/20/2012 23:15:13.969","47","47","48","18"
"01/20/2012 23:20:13.975","47","47","45","17"
"01/20/2012 23:25:13.980","44","44","44","17"
"01/20/2012 23:30:13.970","43","43","47","14"
"01/20/2012 23:35:13.976","45","45","44","15"
"01/20/2012 23:40:13.966","45","45","43","14"
"01/20/2012 23:45:13.971","42","42","44","14"
"01/20/2012 23:50:13.977","44","44","44","13"
"01/20/2012 23:55:13.966","44","44","42","12"
I need the next result:
"01/20/2012 23:10:13.979","49","49","48","19","165"
"01/20/2012 23:15:13.969","47","47","48","18","159"
"01/20/2012 23:20:13.975","47","47","45","17","156"
"01/20/2012 23:25:13.980","44","44","44","17","149"
"01/20/2012 23:30:13.970","43","43","47","14","147"
"01/20/2012 23:35:13.976","45","45","44","15","149"
"01/20/2012 23:40:13.966","45","45","43","14","147"
"01/20/2012 23:45:13.971","42","42","44","14","140"
"01/20/2012 23:50:13.977","44","44","44","13","145"
"01/20/2012 23:55:13.966","44","44","42","12","142"
Im neewbie with awk, i try with:
awk '
BEGIN {FS=OFS=","}
{
sum=0; n=0
for(k=2;k<=NF;k++)
{sum+=$k; ++n}
print $0, sum
}'file.txt > newfile.txt
But its just add a 0 at the end.
I'm stuck with this for a couple of hours, any idea? THX A LOT!!