Home > Commands A-M > Commands Ch-Cz

COMP


Description | Syntax | Parameters | Switches | Related | Notes | Examples | Errorlevels | Availability

Compares the contents of two files or sets of files to find information that does not match.


Syntax

COMP /?

COMP [d:][path][filename] [d:][path][filename] [/A] [/C] [/D] [/L] [/N=nnn] [/OFF[LINE]]

Prompt for the file(s) and any options:

COMP


Parameters
d: ( path filename v2.0 NT3.5)
Specifies location and name(s) of first (set) file(s) to compare. To compare sets of files, use wildcards.
d: ( path filename v2.0 NT3.5)
Specifies location and name(s) of second (set) file(s) to compare. To compare sets of files, use wildcards.

Switches
/? (NTXP)
Display help.
/A (v5.0 NT3.5)
Displays the differences found between compared files as ASCII characters. (Similar to the way FC worked).
/C (v5.0 NT3.5)
Do a case insensitive string comparison.
/D (v5.0 NT3.5)
Displays the differences found between compared files in decimal format. (The default format is hexadecimal.)
/L (v5.0 NT3.5)
Displays the number of the line where the difference occurred, rather than the byte offset.
/N=nnn (v5.0 NT3.5)
Compare only the first nnn lines in the file(s), even if the files are of different sizes.
/OFF[LINE] (NTXP ONLY)
Do not skip files with offline attribute set.

Related

Replaced by FC (Compare two files and display any LINES which do not match) command in later Versions.
Equivalent Linux BASH commands:
comm - Compare two sorted files line by line
cmp - Compare two files
diff - Display the differences between two files
diff3 - Show differences among three files
sdiff - merge two files interactively


Notes
Files must contain an END-OF-FILE character

Before starting the comparison, the program checks to see if files contain a valid end-of-file mark. COMP will not compare files that do not contain an end-of-file marker. If a specified file does not contain such a mark, the error message will be displayed:

    EOF mark not found

This mark is created by your word processor or other application program to indicate the end of the file. You can create the end- of-file marker by pressing and holding the Ctrl key and then pressing the letter Z key.


Comparing files of different sizes

The COMP program also checks to make sure the file sizes indicated in the directory are the same for compared files. If the two files have different file lengths, Comp (for v3.20 and later will prompt to see if you want to continue. Prior to v3.20, Comp just quits if the files are different lengths.


Prompted comparisons

If you enter one or more pathnames or filenames after the command name, when you press the Enter key the comparison will begin immediately; therefore, you should make sure the diskette(s) containing the files to be compared are already in the specified drives. If you want to change diskettes after entering the command, enter the command name with no parameters. If you enter the COMP command with no options , the program will prompt you for the file and/or path designations.

First, the program will display:

    Enter primary filename

Enter the name of the first file or group of files. Next, the program will display:

    Enter 2nd filename or drive ID

After you enter the second filename(s), the program will compare the files, issuing reports on its progress.

If the files are identical, it will report:

    Files compare OK

If the files are not identical, it will report on the differences it finds.

COMP will display the memory locations of any portions of the compared files that do not match. After ten mismatches, the program terminates the comparison. The message is displayed:

    10 Mismatches - ending compare

After all pairs specified have been compared, COMP will display:

    Compare more files (Y/N)?

To enter more files to compare, press the letter Y key. To terminate the comparisons, press the letter N key.


Examples

To compare all the files ending in .TXT on drive A with all of the files ending in .TXT on drive B, enter

    COMP A:*.TXT B:

To compare all of the files in the LETTERS directory on drive A with all of the files in the LETTERS directory on drive B, enter

    COMP A:\LETTERS B:\LETTERS

Every file on drive A with an extension of .DAT is compared against files with the same names on drive C.

    COMP A:*.DAT C:*.DAT

Errorlevels

none.


Availability
External
DOS
v1.0 v1.05 v1.1 v1.11 v1.24 v1.25 v1.85 v2.0 v2.01 v2.05 v2.10 v2.11 v2.11R v2.12 v2.2 v2.25 v3.0 v3.20 v3.05 v3.1 v3.21 v3.25 v3.30 v3.3A v3.3R v3.3T v3.31 v3.40 v4.0 v4.01 v4.01A v5.0 v5.0A v5.00.02 v5.001A v5.01 v5.02
Windows NT
NT3.5 NT4 NT2000 NTXP NT2003
External Supplemental
DOS
v6.0
Windows
none
Windows NT
none