Computer Hope

Microsoft => Microsoft DOS => Topic started by: dworley on July 03, 2008, 11:11:59 AM

Title: Compare two files
Post by: dworley on July 03, 2008, 11:11:59 AM
I am looking for a command that will allow me to compare the contents of two simple files and return a binary-type response (yes/no, positive/negative, 0/1, something like that).

Ideally, something like this

C:\[*compare*] $temp1$ $temp2$

where the output/return is:

1 (or 0)

Thanks!
-Darryl
Title: Re: Compare two files
Post by: Dias de verano on July 03, 2008, 11:13:17 AM
fcomp.bat

@echo off
set same=0
fc %1 %2>nul&&set same=1
echo %same%


fcomp file1 file2
fcomp "file one" "file two"

echoes 1 to stdout if files are identical, echoes 0 if they are not.