Sum

sum

Sum a sequence of integers from positional parameters or stdin. Non-integer values are silently skipped.

Example

sum 1 2 3          # => 6
printf '%s\n' 1 2 3 | sum   # => 6

Arguments

  • ... (int): Integers to sum, or pipe values via stdin

Exit codes

  • 0: Always

Output on stdout

  • Integer sum

average

Compute the arithmetic mean of numbers from stdin, a file, or positional parameters. With no arguments reads from stdin. With one argument that is a readable file, averages its lines. Otherwise averages the supplied parameters.

Arguments

  • ... (number): Optional numbers to average, or a single file path

Exit codes

  • 0: Always

Output on stdout

  • The average value