Usage - Description - Options - Limitations - Return codes
sum [log logfile] [options] [infile] [to outfile]
sum sums up numbers in infile until end-of-file or non-integer data is found, and prints a one line result to outfile, e.g.:
sum is 540
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.
sum recognizes the following command line options:
Option | Function |
---|---|
-a | Print average of numbers in infile. |
-s | Print smallest number in infile. |
-b | Print biggest number in infile. |
-c | Print count of numbers in infile. |
-v | Print version banner and usage info to standard error (or logfile, if given), then exit. |
sum only handles integer numbers, in the range -2147483647 .. 2147483647.
sum does not detect underflows and overflows.
sum returns with one of the following codes ("error levels"):
Code | Meaning |
---|---|
0 | Success |
2 | Unknown result (sum didn't find any numbers to add up). |
102 | Incorrect command line arguments |
104 | Error opening file |
105 | I/O error |
107 | File name clash |