Andrew
Andrew

Reputation: 53

Identical Text Files (.txt) are not matching

I'm using Terminal to run a curl request to an API, and am storing the result of that request in a text file.

On a subsequent command, I am comparing a previously stored text file to the new text file where the curl request was stored.

Using a tool text comparison software (https://www.diffchecker.com) to identify any changes between the two files. It's stating that a majority of the text has been removed ----- but the text is exactly the same when I read it:O

Has this happened to anyone else? Not sure how to resolve. I can't post the filed online as they are confidential :(

Thanks for the help!

Upvotes: 2

Views: 681

Answers (3)

glenn jackman
glenn jackman

Reputation: 246837

The simplest tool to compare files is cmp

if cmp --quiet file1 file2; then
    echo "files are the same"
else
    echo "files are different"
fi

If you're interested in "what changed?" then use diff or comm

Upvotes: 3

Gizmo_the_Great
Gizmo_the_Great

Reputation: 979

Use the 'compare files' of HxD (Analaysis --> File Compare --> Compare, followed by F6 for each subsequent difference) which will highlight which byte(s) are different in a visual way, and use a hashing tool like QuickHash you can be certain whether the files are different or not, for certain.

Upvotes: 0

omer727
omer727

Reputation: 7565

There a good chance there a difference in the invisible characters. Like space and new lines. You can take an advanced editor like notepad++ and ask him to show invisible chars

Upvotes: 0

Related Questions