Using diff to perform the mapping between line numbers of two almost similar files
I have a text file and its updated version.I need to use diff command to discover the difference in line numbers in between the two text files.Is there any way by which i could directly get the mapping betwen the line numbers. Currently i use this code diff -ab file1 file2 and this outputs me
15a16 > 27c28,30 < parameter [3:0] state12=4'b 1011; --- > parameter [3:0] state12=4'b 1011; > parameter [3:0] state13=4'b 1100; > parameter [3:0] state14=4'b 1101; 55c58,59 < next_state = state02; however i would like something on these lines 1,1 2,3 3,4 4,6
where the 1st number is the line number in the file1 and the second number is the corresponding line number in file2.Else i would have to write a script in python to decode the use of a,c.d Thanking you in advance
To do this, you need a diff tool that can recognize when code has moved, not merely been inserted/deleted.
Our Smart Differencer family of tools can do this. SmartDifferencers parse the code text using a real parser, and then matches where phrases are moved/copied/modified. The output identifies for each original code block that change somehow, precise down to the line and column numbers, whether code has been deleted, moved, copied, etc. There are SmartDifferencers for many standard programming languages (you seem to working with Verilog, and yes there is one for that).
You'd still need a script to convert the SmartDifferencer output into the form you are looking for.