Question concerning DIFF

Hey,

I am running a linux shell script containing some php. I want to be able to do a DIFF on two files...if the files are identical, set an exit status of 0, and if they are different, set an exit status of 1.

I have been looking long and hard on how to do this, but I don't think that I can with DIFF. Does anyone know of any alternatives? Or anyway I can achieve this?

Here is how I am doing the DIFF:

$reg_test = "diff -s FILE_A FILE_B";
exec("$reg_test");
diff -q file1 file2
if [ ! $? -eq 0 ]
then
  do something
else
  do something else
fi

Note: This is /bin/sh, not php. You can use this through the system() or passthru() functions.

I'll give that a try, Thanks :slight_smile:

On my machine, if I read the man page for diff, I see:

Exit values

   Exit status is 0 for no differences, 1 for some differences, 2 for errors.

So what else do you need???