If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Compare / Differences in two ASCII files

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-15-06, 13:31
gauravjain21 gauravjain21 is offline
Registered User
 
Join Date: Mar 2005
Posts: 41
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.
Reply With Quote
  #2 (permalink)  
Old 11-15-06, 14:37
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
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
Reply With Quote
  #3 (permalink)  
Old 11-19-06, 07:21
gauravjain21 gauravjain21 is offline
Registered User
 
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
.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On