Skip to content
Advertisement

Add up a column of numbers at the Unix shell

Given a list of files in files.txt, I can get a list of their sizes like this:

JavaScript

which produces something like this:

JavaScript

How can I get the total of all those numbers?

Advertisement

Answer

JavaScript

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

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

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement