this is part of a KT i am going thru.
i am writing a script in bash shell, linux where i have 2 columns where 1st signifies the nth hour like 00, 01, 02...23 and 2nd the file size.
sample data attached.
Desired output is 3 columns which will give the nth hour, number of entries in nth hour and sum of the file sizes on nth hour.
i am trying below code but it's not working.
for (( i=00; i<=23; i++ ))
do
filecount=`awk '{if ($1 == "$i") print $2;}' interim.txt |wc -l`
filesize=`awk '{if ($1 == "$i") print $2;}' interim.txt | awk '{sum += $1} END {print sum}'|awk '{filesize=$1/1024/1024; print filesize"MB"}'`
echo $i $filecount $filesize >> report.txt
done
any help would be greatly appreciated.
ty.