Previous | Table of Contents | Next |
DESCRIPTION
The external sum command calculates a checksum and block count for a file.The checksum of a file is basically the sum of the values of all bytes stored in the file (or some variation of masking or shifting each byte). A checksum is useful for file validation. You can use sum to validate file transmission to a different system worked. Another use is to save a file to tape, reload the file, and rerun sum to compare that the version on the tape and the original files are the same.
Some versions of sum are not compatible between different versions of UNIX. Therefore, you should use sum when moving files between like architecture. You may use it between different architectures but should probably perform a simple test on a known ASCII file. For example, create a two- or three-line file (assume you use newfile as the filename). Execute
cj> sum newfile 46412 1
on the system you created the file. Transfer the file to a target system. Execute
hostx> sum newfile 46412 1
on the target system. If the checksums are the same, then the two system sum programs are probably compatible. Display the contents of the new file and visually compare the contents of the original and the new file.
COMMAND FORMAT
Following is the general format of the sum command.
sum [ -r] file_list
| |
BSD (Berkeley) | |
---|---|
sum file_list | |
|
Options
The following describes the option and the argument that may be used to control how sum functions.
-r | Forces sum to use a different algorithm to check the file. |
|
BSD (Berkeley) |
---|
BSD does not support the -r option. |
|
Arguments
The following argument may be passed to the sum command.
file_list | The name of one or more files to check the sum of all the bytes in each file. |
DIAGNOSTICS AND BUGS
If sum has a problem reading the file, the following message may be displayed.
Read error
This usually means sum tried to read past the end-of-file.
RELATED COMMANDS
Refer to the wc command described in Module 154.
APPLICATIONS
You can use the sum command to checksum a file before you transmit it across communication lines. Then when it arrives you can checksum it on the destination system with sum to verify that it arrived without errors. This procedure is often used to verify release tapes that were saved and reloaded without read or write errors.
It may also be used to check for bad spots in a file. The system administrator may use it to check for tampering among system files.
TYPICAL OPERATION
In this activity you use the sum command to checksum a file before and after you copy it to a new directory. Begin at the shell prompt.
Previous | Table of Contents | Next |