add up numbers in a file

Posted on 1999-12-30
Medium Priority
Last Modified: 2010-04-21

How can I simply add numbers in a file (each line a number)!
it's easy to write a script, but I'm convinced, there must exist a command to do this ...
for example I can use
(cat xx|xargs -iX echo -n "X + ";echo 0) | bc
but this isn't really very performent!!!
do you know something better?

Question by:witty

Author Comment

ID: 2314982
Edited text of question.

Accepted Solution

BigRon earned 200 total points
ID: 2314986
nawk '
{tot += $1}

{print tot} <yourfile

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question