Displays the checksum and block count of a file.
The sum command reads the file specified by the File parameter and calculates a checksum and the number of 1024-byte blocks in that file. If no options are specified, a byte-by-byte algorithm, such as the BSD 4.3 default algorithm, is used. If no files are named, the standard input is read. The checksum and number of 1024-byte blocks are written to standard output. The sum command is generally used to determine if a file that has been copied or communicated over transmission lines is an exact copy of the original.
Item | Description |
---|---|
-i | Allows the user to compute the checksum without including header information, if the input file is a binary file. If the input file is not a binary file, the checksum includes header information. |
-o | Uses the word-by-word algorithm to compute the checksum. The sum command with the -o flag is compatible with the Version 2 sum command in terms of the checksum, but not the number of blocks. |
-r | Uses a byte-by-byte algorithm to compute the checksum. Using the -r flag is the same as using no options. |
This command returns the following exit values:
Item | Description |
---|---|
0 | Successful completion. |
>0 | An error occurred. |
To display the checksum of, and the number of 1024-byte blocks in, the file1 and file2 files, type:
sum file1 file2
If the checksum of the file1 file is 32830, the checksum of the file2 file is 32481, and the file1 file contains one block, and the file2 contains four blocks, the sum command displays:
32830 1 file1
32481 4 file2
Item | Description |
---|---|
/usr/bin/sum | Contains the sum command. |