shell script to compare file contents

Hello

Has anyone got an example shell script that I can use to compare the contents of two files.

The files should contain the same contents, eg.

file1.txt

apple
pear
grape  

file2.txt

apple
pear
grape  

If the file2.txt is different I want to error on this or log it into another file.

Dee

This question is asked very often in here. Please use the search function of the forum and see if you find a fitting thread. Maybe use the words "compare files difference" and you get plenty of hits with solutions.

yes your right maybe I should have done that first....red faced....