Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Posts
    41

    Unanswered: Compare / Differences in two ASCII files

    I am trying to find differences between two files. I know I can use diff or cmp command but I a looking for results to be useful or descriptive.

    In sense, I am looking for differences where line number, position_from to position_to, and string_value is mentioned for both files.

    Pls help me in the code / script.

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    Did you try the "-e" option from diff?


    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Mar 2005
    Posts
    41

    Difference is not user friendly

    File1: a.txt

    $ cat a.txt
    ABC|1|11|3333|dog
    ABC|1|11|3333|dig
    ABC|1|11|3633|dug
    ABC|2|11|3333|cat

    File2: b.txt

    $ cat b.txt
    ABC|1|12|3333|dog
    ABC|1|11|3333|dig
    ABC|7|11|3633|dag
    ABC|2|11|3373|cat

    I want to find differences where the line is listed, position from to is listed and the string value is listed between the two files where the difference occurs.

    I tried your approach, and it gives me differences by lines but imagine if there are 100 delimited columns in a line, how would one find what value(s) are differing. In above two text files, in line 3 there are two differences. The result set does not give both differences but rather stating line number as a difference.

    $ diff -e a.txt b.txt
    3,4c
    ABC|7|11|3633|dag
    ABC|2|11|3373|cat
    .
    1c
    ABC|1|12|3333|dog
    .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •