Sample Header Ad - 728x90

How to make text wrap with diff -y?

2 votes
3 answers
3844 views
When I use diff -y to compare two text files with long lines of text, the result cuts off each column and I cannot read an entire line. I would like instead the text to wrap (or fold as it is also called) so that I can read the whole line. For example, say I have two simple text files one line each:
cat tmp.txt tmp2.txt
The quick brown fox jumped over the lazy dog. This line is very long and will not show when I use a diff. 
The quick brown fox did not jump over the lazy dog. This line is very long and will not show when I use a diff.
diffing them I get,
diff -y tmp.txt tmp2.txt
The quick brown fox jumped over the lazy dog. This line is ve |	The quick brown fox did not jump over the lazy dog. This line
which cuts off the lines in the middle. I know about the -W option to make it wider, but the lines are longer than my screen width so this does not help. Using a simple diff does make the text wrap, but there is no text wrapping with diff -y. So how can I use diff -y with text wrapping? I'm using the terminal on a Mac, if that helps. This seems like a simple thing to want, but after searching everywhere I cannot find a solution!
Asked by xenkan (21 rep)
Aug 26, 2019, 04:12 AM
Last activity: Jul 21, 2021, 07:33 AM