SUM(1) General Commands Manual SUM(1)

sumcompute legacy checksum

sum [-rs] [file]…

Writes a legacy checksum of files (standard input stream "-", the default) to the standard output stream.

Output 3BSD sum. This is the default.
, --sysv
Output AT&T System III UNIX sum.

cksum(1), sha1sum(1)

Appears in the first edition of the UNIX Programmer's Manual as sum(I):

Second and later editions expand the SYNOPSIS to
sum name1 ...
and note that this is a 16-bit checksum, as well as the 512-byte block size and output format: sum, space, amount of blocks read (partial or otherwise), newline, for each file. The algorithm is a simple, literal, sum of every byte into a 16-bit accumulator.

Version 7 AT&T UNIX sees a rewrite in C: it now uses the standard input stream if no files are specified and an updated output format: the sum is zero-padded to 5 digits and immediately followed by the block count, space-padded to six digits (this does mean that a file at least 51.2MB in size would end up with no spaces between the sum and the block count, but is hardly a problem, as disk packs available for the PDP-11 were 10 megabytes in size at the very top end), followed by a space and filename, if more than one was specified, and a newline. The algorithm also changed, rotating the accumulator right by one bit before each addition.

It also uses <stdio.h> and getc(3), emulating the block count by dividing by BUFSIZ (512), rounded up. This is the version included in 3BSD, which, however, started to define BUFSIZ to 1024 — this is the birth of this implementation's default (-r) format (extended with a fixed space and block count space-padded to a width of 5, for reasons assumed obvious).

AT&T System III UNIX introduced an alternative checksum algorithm, which first added all bytes into a 32-bit accumulator, then reduced it twice to the sum of the the high and low words, and a simple sum, space, block count format. The old algorithm (and format) was available under -r, but in both cases the filenames were written if any were specified. Additionally, both formats continued to use BUFSIZ, which was still 512. The default format is this implementation's -s.

In 4.4BSD, sum was moved to old, and the legacy algorithms became available under cksum -o 1|2, but algorithm 13BSD — had lost its special formatting. Since 4.4BSD-Lite2, sum is provided by cksum.

June 9, 2023 voreutils pre-v0.0.0-latest