how to manipulate with lines while playing with data

hello everyone,

well I have a file which contains data, I want to add the data on hourly basis, like my file contains data for 24 hours, (so a total of 1440 [60*24]) lines.

Now i want to add the data on hourly basis to get average values.

like if I use (head) command it is ok for first go, but for next next step how can I use it starting from 60 to 120 and so on.

for the first case (from 0 to 60 sec i.e. one hour) i use awk utility and its giving me correct result but for further i cant. Here is the code for first case:

awk 'BEGIN{total=0}
{total += $1}
END{print total}' test.wri

Please Help:D

How about ...

head -n 120 | tail -n 60

thnkz dr.house, for your reply, but for the below code the output is the last 60 lines of the file....

can u please advice me further....:confused:

Try

$ awk '{ total += $1 } NR % 60 == 0{ print total ; total = 0 }' filename

hahaha my GOD agn, you are simply awesome.

Thnkz for helping me this way... now can you please describe me a bit regarding this code i'll be grateful to you..

I mean how this code is working

NR represents record number(line number) in awk. So 'NR % 60 == 0' checks if the current line is 60th line and prints the total if it is the 60th line.