http://qs321.pair.com?node_id=1017891


in reply to perl onliner on multiple files

Seems to work fine (on a reasonable number of files) if you want the total sum. If you want the sum per file, a minimal change would be to print and reset $c after each file ends.

For example:
perl -e ' while (<>) { if (/: /) { $c += (split /: /)[0]; } if(eof) { print "SUM.$ARGV =$c\n"; $c=0; } }' tmp_*