Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jul 132010
 

How to sum a file of numbers?

Answer:

Assume you have a text file with numbers, one line one number, e.g.

1
2
3
4
5
6
7
8
9
10

You can use the paste and bc command for this tasks.

# paste -sd+ num.txt | bc 
55

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>