Hamilton LaboratoriesHamilton C shell 2012User guideExternal utilities

sum

Oregon Coast

sum
Previous | Next

        Checksum the Contents of a File

Usage:  sum [-prxh-] [ file1 file2 ... ]

   sum checksums the contents of each of the files you specify,
   writing the results to stdout along with a count of the number
   of 512-byte blocks it read (including any partial blocks.)  If
   no files are given, sum reads from stdin.  sum is typically
   used to validate a file communicated over a possibly noisy
   communications line.

   sum treats the characters it reads as 8-bit unsigned integers
   and normally just adds them together to form a 16-bit unsigned
   result.  Overflows are ignored.

Options:

   -p         POSIX checksum.  Use the ISO-8802-3 CRC-32 poly-
              nomial to calculate a cyclic redundancy check for
              each input file and to write that value along with
              a count of the number of bytes (not blocks) to
              stdout.
   -r         Rotated checksum.  Rotate the accumulated checksum
              right one bit position before adding each character.
   -x         Xor'ed checksum.  For each new character, c, the
              checksum, i, is calculated as i += (i << 1) ^ c.
   -h         Help.  (This screen.)
   --         End of options.

   (The default and rotated checksums are the same as those
   calculated by the Unix System V sum command; the xor checksum
   is unique to this implementation.)

Previous | Next