Add up a column of numbers at the Unix shell

... | paste -sd+ - | bc

is the shortest one I've found (from the UNIX Command Line blog).

Edit: added the - argument for portability, thanks @Dogbert and @Owen.


Here goes

cat files.txt | xargs ls -l | cut -c 23-30 | 
  awk '{total = total + $1}END{print total}'

cat will not work if there are spaces in filenames. here is a perl one-liner instead.

perl -nle 'chomp; $x+=(stat($_))[7]; END{print $x}' files.txt