Search code examples
sqlunixinformix4gl

how to diff and show only exact differences for 2 long string


I have 2 files- a and b.

a

1,"abc","( @docid =""00123"" or @docid =""00456"") AND a_number is not NULL"

b

1,"abc","( @docid =""00123"" or @docid =""00456"") AND @a_number is not NULL"

How do I diff this 2 files and show only the part changes in a_number instead of the whole string?


Solution

  • I like to use

    $ wdiff a b
    
    # 1,"abc","( @docid =""00123"" or @docid =""00456"") AND [-a_number-] {+@a_number+} is not NULL"
    

    Notice that wdiff includes a single line with annotations that indicate the portions of the line that were different. The differences are shown in words (hence the name wdiff for word differences).

    In this case, this output

    [-a_number-] {+@a_number+}
    

    shows that the string a_number was changed to @a_number.