How to compare 2 Pages documents

pages

I worked for a long time on a Pages document: file.1.pages.

I didn't activate Edit > Track Changes.

I saved the modified Pages with a new name: file.2.pages.

Now I would like to check I didn't forget a key point or made any error
and review all the modifications I made.

How may I compare file.1.pages and file.2.pages?

This isn't a comparison I can deal with manually (too much text, too many small spelling fixes).

I can't use any Microsoft software. I can use any Unix command line.

Best Answer

Here is how to proceed. The receipe isn't as simple as I thought.

  1. From Pages export files to plain text:

    File > Export > Plain Text...

    so as to get 2 files: file.1.txt, file.2.txt.

  2. Open both files with vi and apply the following command:

    :%s,+V+M,+V+M,g

    this command contains twice the sequence control+V, control+M which is the way to enter the raw return character. The strange effect of this command is to replace any return character (0x0d) with a standard newline character (0x0a) everywhere (g = global). Then the 2 files are now splitted in different lines and it becomes useful to compare them with any Unix text tool.

  3. Change the 2 files encoding:

    :set fileencoding=utf-8

    so as to encode them as text files (and not binary files as they were exported from Pages).

  4. Save the two files and quit vi:

    :wq

  5. Run the standard diff command to compare the 2 text files:

    diff file.1.txt file.2.txt