http://www.perlmonks.org?node_id=896719

bjohn has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am using the diff command to compare 2 output files. The output needs to be identical but im having trouble understanding how to fix it. can u help me?
0a1,4 > For a= 2.000, b= 5.000, c= 1.000: Two solutions for x: -0.219 an +d -2.281 > For a= 2.000, b= 4.000, c= 2.000: One solution for x: -1.000 > For a= 5.500, b= 8.000, c= 2.200: Two solutions for x: -0.368 an +d -1.086 > For a= -2.000, b= 5.000, c= -3.000: Two solutions for x: 1.000 an +d 1.500 2a7 > For a= 5.000, b= 10.000, c= 0.000: Two solutions for x: 0.000 an +d -2.000 3a9 > ERROR: Input must have 3 coefficients, line read had 2 5d10 < For a= 6.457, b= 7.735, c=100.787: Two solutions for x: 0.000 an +d -2.000

Replies are listed 'Best First'.
Re: diff command
by ikegami (Pope) on Mar 31, 2011 at 19:53 UTC
    Fix what?
      I do not understand what this means. 0a1,4 means and how to make the output files identical

        I do not understand what this means. 0a1,4 means

        "a" denotes an addition. "d" denotes a deletion. The numbers on the left form a range of line numbers in file1. The numbers on the right form a range of line numbers in file2.

        and how to make the output files identical

        Some options:

        cp file1 file2
        cp file2 file1
        truncate -s 0 file1 file2
        From man diff:
        These lines resemble ed subcommands to convert file1 into file2.
        See man ed

        I prefer the unified diff format, it is usually easier to read than the traditional format. You can get that format with the -u parameter, i.e. diff -u old new (at least with GNU diff).

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)