xxxxxxxxxx
# this will print if they're identical or not
diff file1 file2 -s
xxxxxxxxxx
if diff -u "$file1" "$file2"; then
echo "$file1 and $file2 have identical contents"
else
: # the differences between the files have been listed
fi
xxxxxxxxxx
if cmp -s "file1" "file2"
then
echo "The files match"
else
echo "The files are different"
fi
xxxxxxxxxx
#!/bin/bash
file1="file1.txt"
file2="file2.txt"
if cmp -s "$file1" "$file2"; then
echo "Files are identical."
else
echo "Files are different."
fi