in reply to Reading concurrently two files with different number of lines

Depending on your files, would it help to first run them through diff, which is very powerful, and then look at the output of that rather than comparing the tow files themselves?

Replies are listed 'Best First'.
Re^2: Reading concurrently two files with different number of lines
by frogsausage (Sexton) on Apr 11, 2013 at 09:33 UTC
    I don't think this would work as diff compares line by line. Meaning that if I have:
    ABC a b + value=3.14 + value2="name"
    and
    ABC a b + value="other" + value2="name"

    Then I would have either 1 or 2 lines (depending if returning matched or unmatched lines), which is not what I want. I need to have the full 'line' (starting with a letter plus all the following starting by a +) if either of these are different.

    Unless diff understands and deals with continuation lines, which in case I don't know that.

      diff would not understand the continuation lines, but it doesn't necessarily have to. You can break your problem into two parts, and attack them individually:

      1. Normalize your inputs
      2. Compare your inputs

      The first you would do with Perl. Write a script that just handles the line continuations and normalizes your input into a "clean" format.

      You could then use diff to do the actual comparison between the two files. If diff doesn't meet your requirements for some reason, your comparison code would still be cleaner and simpler for not having to deal with the line continuations.

      Christopher Cashell
        Thanks for the details. In the end, I already had my line to be compared in an array, so I just ended up using string comparison.

        I gave my "solution" below following my code working great here :)