0

diff -y file1 file2 creates output like this:

enter image description here

I want to take this output and convert it to a CSV format where

  • the text at left is in one column,
  • the < or | or >, if any, is in the second column, and
  • the text at right is in the 3rd column.

The point of this is to be able to use common productivity software to discuss diffs with non technical users that I cannot expect to install pull review software.

I am not married to diff as the starting point to the solution if there are better options, but the outcome has to be a three column exportable file.

3
  • 1
    If you replace for example the " < " by ",<," and so on, this would become a CSV file.
    – harrymc
    Commented Nov 12, 2021 at 21:01
  • @harrymc this wouldn't work for all the lines with no |, <, or >. if you filter those out you wouldn't have much idea of where the insertion was.
    – Merk
    Commented Dec 1, 2021 at 17:20
  • You may use the long string of blanks, if no such exist inside the text.
    – harrymc
    Commented Dec 1, 2021 at 17:48

1 Answer 1

1

Not sure if it works in Excel, but I've had good results in LibreOffice Calc using constant-width fields when importing the diff output. For example:

diff -yt file1.txt file2.txt > diffoutput.txt

The -t option is useful for dealing with tab characters. You can adjust the diff output line width with the --width diff parameter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .