Input File:
2000 3
1998 2
1997 2
1994 1
1991 1
1989 1
1987 2
1986 2
1985 1
1984 1
.
.
10 277256
9 278274
8 282507
7 284837
6 287066
5 292967
4 314583
3 342942
2 441704
1 487042
Desired Output
2000 110
1900 163
1800 139
.
.
.
200 3557341
100 13454579
Code Try:
awk '$1>=1901&&$1<=2000{total = total + $2}END{print total}' Input_File
110
awk '$1>=1801&&$1<=1900{total = total + $2}END{print total}' Input_File
163
awk '$1>=1701&&$1<=1800{total = total + $2}END{print total}' Input_File
139
awk '$1>=101&&$1<=200{total = total + $2}END{print total}' Input_File
3557341
awk '$1>=1&&$1<=100{total = total + $2}END{print total}' Input_File
13454579
I plan to sum the column 2 if column 1 is within every 100 group.
eg.
Sum all the column 2 value if column 1 is range within 1 to 100;
Sum all the column 2 value if column 1 is range within 101 to 200;
Sum all the column 2 value if column 1 is range within 201 to 300;
Desired output should have 20 line which column 1 is every 100 and sum its corresponding column 2 data (maximum record in data set is 2000).
The command I try is quite tedious as I need to type the command one by one from 1 to 100 till 1901 to 2000 and sum its corresponding column 2 data.
Thanks for any advice.