Using diff on a long one line file

Assuming that there are many whitespaces, as in normal text, you can split the file by words and compare it with a normal diff tool, for example, meld:

tr -s ' ' '\n' < file1.txt > file1.txt.split
tr -s ' ' '\n' < file2.txt > file2.txt.split
meld file1.txt.split file2.txt.split

I'd find a diff that does intra-line diffs. I use xxdiff on UNIX. I think WinMerge does intra-line diff on Windows.

The other answers are good as well: wdiff, or breaking into chunks - the chunk boundaries are easier to define if the data is delimited by say a pipe or a comma.


If this is a one-time problem, I'd create copies of the files with \n characters inserted every 50 characters, then diff those copies. (I chose 50 because it makes the math easy going from differing line number to byte offset in the original files but might adjust that up/down based on what I found.)