#!/usr/bin/perl $|=1; while(<>) { chomp; /wrote (\d+) bytes.*read (\d+) bytes/oi or next; $wrote+=$1; $read+=$2; } $total=$read+$wrote; foreach $i ("read", "wrote", "total") { printf("%-10s: $$i\t(%03.3fMb)\n", $i, $$i/1024/1024); }