Shell Script to Compare Two Files

I have a directory with about 6 files that we receive regularly. these 6 files contain information for 3 different units, 2 for each unit. files related to a specific unit are named similarly with a change in number at the end of the file. the numbers should be sequential. for each grouping of files related to a unit, how do i 1 -make sure the numbers in the two filenames are sequential and 2 - check to see if they are duplicates? I need to do this in a shell script (.sh)

example.

Unit1.CAT.T123Q
Unit1.CAT.T124Q
Unit2.DOG.P325D
Unit2.DOG.P326D
Unit3.Mouse.Q765F
Unit3.Mouse.Q766F
#!/bin/bash

# Put the numbers in an array
N=( $(ls|sort|sed "s/[^0-9]*$//;s/^.*[^0-9]//") )

# Test the numbers
if [ ${N[0]} = ${N[1]} ]  ||  $((${N[0]}+1)) != ${N[1]}; then
    echo Problem
fi

# Repeat for 2,3 and 4,5 or make a loop

Although, you said about 6 files. If there aren't exactly 6 files as you describe, you'll need to add more checks, of course.

Thanks. this is perfect. now how do i make sure they are not duplicates...like based on the bytes or filesize? the first check will be to verify the number sequencing and the second check needs to make sure they are not duplicates (based on filesize or bytes).

That sounds like a job for cmp.

if cmp -s $FILE1 $FILE2; then
    echo Duplicate
fi