I'm developing a web application which downloads a number of web pages using PHP curl. It then uses diff
to compare the files as they change each day.
I reported a problem a few weeks back where seemingly identical files were being flagged by diff
as being different: https://stackoverflow.com/questions/42552239/different-versions-of-diff-giving-mixed-results-when-comparing-2-identical-fil
The answer to the above was that if diff
was used with the -w
flag it ignores whitespace.
However, I've now noticed a separate problem. If I download one of the files I'm comparing, and re-upload (overwrite) it through an FTP client, the output changes.
For example: Compare file1.html
against file2.html
with diff file1.html file2.html
it may give output such as
12159,12161c12159,12161
<
<
<
---
>
>
>
12163,12172c12163,12172
<
<
<
<
<
<
<
<
<
<
---
However, if I download file2.html
to my desktop and re-upload it through FTP, diff
without the -w
flag reports there being no differences at all i.e. it's now saying the files are identical.
I've tried to check the encoding of the file using file -bi file2.html
but it's reported the same before and after upload through FTP. The encoding is text/html; charset=us-ascii
If the encoding is no different and the file contents have not been modified, how is re-uploading the file through FTP changing anything?? I've tried it using FileZilla and also through Netbeans.
I'm using macOS Sierra locally and the remote server is Apache 2/PHP 7/centOS.