0

So my question is related to : diff where lines are mostly the same but out of order? but is slightly different, in that in this case sorting won't work.

I have 2 files and I want to do a diff between them, but as in the previous case the lines are out of order. Unlike the previous case though, the lines come in chunks of 5 and I want to make sure that these chunks are all the same. As an example, I'll do a two chunk line file difference

file1.txt
    1a
    2a
    1b
    2b

file2.txt
    1b
    2b
    1a
    2a

file3.txt
    1a
    1b
    2a
    2b

If we look at a diff between these files, all of them will come back as different. If we do a sort first and then a diff then we will again have all three files be the same. BUT for me file3.txt is not the same because the lines would come in pairs. So because we have 1a,2a in file1.txt and 1a,1b in file3.txt I'd want that marked as different.

Is there a nice/simple way to do this, or is creating a script going to be the only way to achieve this?

  • the lines come in chunks of 5 - I see only chunks of 4 in your input. Why? chunks of 5 would not correlate with pairs of lines. Elaborate your conditions – RomanPerekhrest Jan 21 '18 at 10:36
  • The input is an example of chunks of two. So each two lines count as 1 chunk. (FIgured a two chunk example would be easier to read than a 5 chunk example) – Aram Papazian Jan 22 '18 at 7:14

Your Answer

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

Browse other questions tagged or ask your own question.