SUM v2.01 - find sum of numbers in text file
Documentation revised 21 Oct 00 - Copyright (c) 1996-2000 by Rune Berg. TextTools Freeware.

Contents:


Usage Top || Next

sum [log logfile] [options] [infile] [to outfile]

See Understanding The Usage Section for details.


Description Top || Previous || Next

sum sums up numbers in infile until end-of-file or non-numeric data is found, and prints a one line result to outfile, e.g.:

      sum is 540

If all input numbers are integers, sum will print an integer result; if at least one input number is a floating point number, sum will print a floating point result.

If sum finds no numbers in infile, it will print:

      sum is unknown

If you don't specify infile, sum reads from standard input.
If you don't specify outfile, sum writes to standard output.
If you don't specify logfile, sum writes error messages to standard error.


Options Top || Previous || Next

sum recognizes the following command line options:

The functions -a -s -b -c -u can be used one at a time (to print just that kind of result), or combined (to print more than one result).


Example Top || Previous || Next

Given a file mydata.txt containing:

      3
      5
      1
      33

the command:

      sum -usb mydata.txt

will print:

      sum is 42
      smallest is 1
      biggest is 33


Limitations Top || Previous || Next

sum handles integer in the range -2147483647 .. 2147483647.

See separate discussion on floating point numbers for more details on that format.

sum does not detect underflows and overflows.


Return Codes Top || Previous || Next

sum returns with one of the following codes ("error levels"):

For more details, see TextTools General Features.


Version History Top || Previous

These are the released versions of sum:

End of document