Diff: How do you only compare the first n characters in each line?
In bash, you can use process substitution.
To remove last 40 characters, you can use
diff <(sed 's/.\{40\}$//' file1) \
<(sed 's/.\{40\}$//' file2)
To select the first 40 characters, you can use
cut -c1-40 file