Hi,
i have 2 files like f1 and f2
f1:
1
Note: some times it will be cahnged to 2 and 3.
f2:
1:20
2:30
4:50
6:70
8:90
3:20
1:30
1:40
output:
1:80
(sum of 1)
for this i wrote awk script.but it's not working.
cat f1.txt | awk '
BEGIN {
FS=":"
load_type=$1;
}
{
number[$1]++;
totaltime[$1]=totaltime[$1]+$2;
}
END {
f ( load_type==1 )
workload="Light_load_avgfile";
else if (load_type==2)
workload="Medium_load_avgfile";
else
workload="Heavy_load_avgfile";
for\( code in totaltime \)
\{
\#calculating avg;
avg=totaltime[code]/number[code];
print code"|"avg "|">workload
\}
}' f2.txt
please help me on this