Search Results

Search: Posts Made By: Saravanan_0074
3,217
Posted By mjf
How about removing the hour? awk -F'|'...
How about removing the hour?

awk -F'|' 'NR>2 {array[$1] += $3 count[$1]++ } END { for (a in array) {print a, array[a]/count[a] } } '
3,217
Posted By Don Cragun
Unlike many languages where two adjacent strings...
Unlike many languages where two adjacent strings representing numbers separated by a space would be a syntax error, awk is happy to concatenate them and treat them as a single numeric string.

So...
3,217
Posted By mjf
I understand the concatenation but what I'm not...
I understand the concatenation but what I'm not getting is why the extra digits being added are off by one for each line. For example, for line 3, I would expect the extra digit in red to be 1...
3,217
Posted By Don Cragun
I have only tested this with the given data, but...
I have only tested this with the given data, but I'm surprised that you're showing sample output that includes the data marked in red above when there was no sample input for that date. When I tried...
3,217
Posted By mjf
Don, Yes, I added another test record with...
Don,
Yes, I added another test record with 3/3/2015 date to test the break logic and forgot to remove it from posted output (as OP did not include it in his file). I missed the semi-colon although...
Showing results 1 to 5 of 5

 
All times are GMT -4. The time now is 10:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy