How to Compare two files depend on line length Chars

I need to compare two files with exactly same length as example: -

File1 contain 500 records with length of 640 chars of each line.
File2 contain 1500 records with length of 640 chars of each line.

I need get an output to be written in File3 which will contain 1000 records difference.
but my diff will be based on line length which is 630 chars and ignore the remaining 10 chars in comparing.
However, file3 I wanted to include all 1000 records with 640 chars lenght for each line.

Thanks in advance

Try:

paste file1 file2  | awk '{ str1=substr($1,0,629); str2=substr($2,0,629); if(str1 != str2) print str1"\n"str2; }' > file3

Many Thanks for your swift reply,

However, this is not what I am looking for, let me example it to be easier for understanding in order to help me.

File1 contain 500 records and each line lenght has 640 chars
File2 contain 1500 records and each line length has 640 chars.

Now;
My File2 will be my source, I need one line length of 630 chars from File2 to check if it's exist in File1, If yes, then go to second line search.
Else, copy this line into new file (File3) but this time with exact line length of 640 from the orginal instead of 630 chars.

I hope this make it clear.

Thanks.

This should work:

while read l;do test $(grep -c ${l:0:630} file1) -eq 0 &&  echo "$l" >> file3 ;done < file2

Dear,

Thanks for the help, but still this didn't help me :frowning: