I have a file that has only one line. Its size is about 20,000 bytes.

The file has been modified, and I wanted to know where.

I thought using diff, but it shows me the complete line, because it outputs the line that has the difference - but in this case it's the only line in the file that has differences.

So I wanted to see what is the difference.

Any advice?


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
  • 2
    Seems to be the most straightforward solution for me. The diff problem in itself is trivial, however most tools (not just diff-tools) can't manage long lines, so the problem is dealing w/ long lines rather, not the diffing itself. – p1100i Feb 24 '15 at 10:53

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.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.