#!/usr/bin/env perl use Getopt::Std; getopt('d'); $delimitter = (defined $opt_d) ? $opt_d : '\s+'; while (<>) { print; @c = split(/$delimitter/, $_); for (0..$#c) {$sum[$_] += $c[$_]} } print "#", join(",", @sum), "\n";
% ll *.txt | gok -rwxr--r-- 1 yto yto 50668 Jul 5 2002 a1.txt -rwxr--r-- 1 yto yto 50584 Jul 4 2002 a2.txt #0,2,0,0,101252,0,9,4004,0 % gok -d , a.csv 2002-12, 83, 0 2003-01, 65, 23 2003-02, 87,109 #6008,235,132