perl -MO=Deparse -lne "$count+=split}{print $count" /path/file1 /path/file2 BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = readline ARGV)) { chomp $_; $count += split(' ', $_, 0); } { print $count; } -e syntax OK