The comp command can compare files on the same drive or on different drives, and in the same folder or in different folders. When comparing files, it displays their location and file name.
The files you compare may have the same file name, as long as they are in different folders or on different drives. If you do not specify the file name for Data2, the default file name for Data2 is the same as the file name in Data1. You can use wildcards ( * and ? ) To specify the file name.
You must specify the / n parameter to compare files of different sizes. If the file size is different and the / n parameter is not specified, the comp command will display the following message:
Files are different sizes
Compare more files (Y/N)?
To compare these files, press N to stop the comp command. Then, run the comp command with the / n option to compare only the beginning of each file.
If you use wildcards ( * and ? ) To specify multiple files, the comp command will find the first file that matches Data1 and compare the file with the corresponding file in Data2, if it exists. The comp command reports the comparison results for each file that matches Data1. When completed, the comp command displays the following message:
Compare more files (Y/N)?
To compare other files, press Y. The comp command will prompt you for the location and name of the new file. To stop comparing, press N. When you press Y , the comp command will prompt you for command line options to use. If you do not specify any command line options, the comp command will use the options you specified earlier.
To compare the contents of the C: Reports folder with the SalesBackupApril backup folder, enter:
comp c:reports salesbackupapril
To compare the first 10 lines of text files in the Invoice folder and display the results in decimal format, enter:
comp invoice*.txt invoicebackup*.txt /n=10 /d
See more: