Home - Resumé - Up


Name

add - add numbers

Synopsis

add [−1bcefinopqsx] [−r radix] [−F format] [source ...]

Description

Add totals numbers from the command line or from files.

The options are as follows:

−1
Interpret at most one number per line. (This flag is the digit 1.)

−b
Numbers are binary (radix 2).

−c
Under the −c flag, add writes the cumulative total for each input number.

−e
Under the −e flag, add copies each input number to the output, exactly as read.

−f
Normally, char treats each source argument as a number and prints the corresponding character. Under the −f flag, char instead takes the source arguments to be file names, and converts every identifiable number in each file.

If no source arguments are supplied, add reads the standard input, with or without −f.

−i
Under the −i flag, add copies each input number to the output, in the same format as the sum.

−n
Do not print a newline after the sum.

−o
Numbers are octal (radix 8).

−p
Pass the input file contents through to the output. Thus add can be used as a filter that appends a total to its input.

−q
Do not print the sum. (Typically used with −c or −s.)

−r radix
Sets the radix (base) for numbers. In the absence of any radix flag, or if radix is zero, then numbers are C-style integers with a optional 0x or 0 prefix.

−s
Set the exit status of add to the sum.

−x
Numbers are hexadecimal (radix 16).

−F format
Specify a format for printing numbers. This format is provided to printf(3) along with a signed long integer. Without the −F option, add prints numbers in the input radix.

If more than one of the flags −c, −e, or −i appear, add prints the corresponding numbers separated by tab characters, in the order that the flags first appear on the command line.

See Also

printf(3) , strtoul(3)