crc(1) — USER COMMANDS
NAME
crc − generate cyclic redundancy checksums (crc) of files
SYNOPSIS
crc [−frcld] { − | f2file_list }
DESCRIPTION
The crc shell command utility is a versatile tool for use in generating 16-bit crc values of an input stream. The input stream can consist either of data or of names of files to be checked. There are four different display options available.
If the file to be checked is an object file, crc will ignore the compiler-generated time stamps embedded in the file.
The various options are defined as:
−f Selects file mode operation. The input stream is interpreted as a list of the names of the files to be processed instead of the data itself.
−r Selects a raw mode of operation. This option is used mainly to determine if two versions of an executable file are exactly the same. This switch causes crc to include the compiler-generated time stamps in the file image when computing the crc.
−c Changes the output to include the byte count of each file processed.
−d Adds the time of the file’s modification to the output.
−l Computes the crc in decimal for each line of the input file instead of the whole file itself. Use of this option overrides all others.
Note that the first four options can be used in any combination. There are three general forms of output. The first form is produced without the −c option:
$nnnn for filename (time stamp)
where $nnnn is the 16-bit checksum in hexadecimal representation; and time stamp is the time of the file’s modification (displayed if the −doption is selected). The fields are separated by space (20h) characters.
The second output form is generated when the −coption is selected:
$nnnn length time stamp filename
where length is the true size of the file, regardless of whether raw mode (−r) is selected; and time stamp is the time of the file’s modification (displayed if the −d option is selected). All fields of this second form are delimited by tab () characters.
The third form of output is produced by the line mode option (−l). It replaces each line of input with its corresponding crc in the form nnnn.
DIAGNOSTICS
crc: bad option letter.
an invalid option letter was specified.
crc: argument count.
At least one file name (or ’-’) must be provided.
crc: can’t open file for reading.
file cannot be opened for some reason.
crc: can’t read file.
input file cannot be read for some reason.
EXAMPLES
Suppose a touch ∗; ls -log command produces the following directory listing:
-rwxrwxrwx 1 23 Apr 8 12:39 apple
-rwxrwxrwx 1 8307 Apr 8 12:39 peaches
-rwxrwxrwx 1 1280 Apr 8 12:39 pears
-rwxrwxrwx 1 771 Apr 8 12:39 plums
Note that ls | crc -fdc - is equivalent to crc -dc ∗, and both would produce output similar to:
$8AC3 23 Apr 8 12:39:51 1986 apple
$FD06 8307 Apr 8 12:39:51 1986 peaches
$C3B0 1280 Apr 8 12:39:51 1986 pears
$02D2 771 Apr 8 12:39:51 1986 plums
A means of generating checksums for an entire directory hierarchy is:
find root_path -type f -print | crc -fcd -
Use of the ’-type f’ option on find is recommended because crc will generate the crc for the directory files themselves if presented with their names.
You can extract just the crc and length from a stream of crc’s by using the cut command. When appended to the above command,
find args -type f -print | crc -fcd - | cut -f1,2
produces an output of two columns: the crc and the file’s length.
NOTES
The crc command is available only on Motorola systems; use the sum command if you need to calculate checksums on both Motorola and non-Motorola systems.
FILES
/usr/bin/crc
SEE ASLO
sum(1), cut(1).
— Directory and File Management Utilities