Reputation: 606
I am working on a test bench to model some hardware. Each line acts as a test-case. I have the following:
File-In --> MyModel --> File-out
I also have a File-reference that my output must match.
When in development, many mismatches exist between the output and the reference. I need to know the line numbers that differ, then copy those lines from File-In to File-In-bugs So I can run MyModel with the buggy lines for quicker debugging.
[Edit] Example for my files
INPUT (Actual workloads have millions of lines)
100 000 0008EDF3FCFF3FCFF3FCFF3FCFF3342B 00084000000000000000000000507F1A
100 000 0008F800000000000000000000000004 80074000000000000000000000420000
101 000 0006C0000000000001A0308801C00000 0008E000000000000000000030A61108
100 000 80020000088C00000000000000000000 8008EDF3FCFF3FCFF3FCFF3FCFF3FF9F
100 000 00090413FCFF3FCFF3FCFF3FBE75EF5B 0006C0000000000014CB826109E00000
101 000 000903B0000000000000001A9CC23829 000840000000000000006A7308E0A410
101 000 00068000000000000000000C08000000 00090220000000000000000000000003
100 000 800902A3FCFF762DE9F248E6F44B625F 9806A1404555A482BB52150248C00000
100 000 0006C0005BE1D493AB588D1E49E00000 00094011E4FF3FCFE68E3CFC3C46251E
100 000 8006C0017B35F0E248B64BC001000000 000940704000000095B6F470A2AB22E0
OUTPUT
14088FF3FCFF3FCFF3FCFF3FCFF3FCFF 00000
18088FF3FCFF3FCFF3FCFF3FCFF3FCFF 00000
8C088FF3FCFF3FCFF3FCFF3FCFF3FCFF 00000
94088FF3FCFF3FCFF3FCFF3FCFF3FCFF 00000
10088DF3FCFF3FCFF3FCFF3FCFF3FCFF 00000
640895F3FCFF3FCFF3FCFF3FCFF3FCFF 00000
88088DF3FCFF3FCFF3FCFF3FCFF3FCFF 00000
E00895F3FCFF3FCFF3FCFF3FCFF3FCFF 00000
04088793FCFF3FCFF3FCFF3FCFF3FCFF 00000
1C088093FCFF3FCFF3FCFF3FCFF3FCFF 00000
REFERENCE files are identical to the correct output, but bugs may lead to change one ore more hex characters. At lines with bugs, the File-In shall be copied to a new file, File-In-bugs. I hope this makes the problem more clear.
What I did so far is not much. I think linux pipes can be useful.
Upvotes: 3
Views: 528
Reputation: 51693
diff --old-line-format '%L' --new-line-format '' --unchanged-line-format '' File-out File-Reference
Will produce an output of only showing the lines that can be found only in File-out
, but it won't provide line numbers. If you really need that in your output:
diff --old-line-format '%L' --new-line-format '' --unchanged-line-format '' <(nl File-out) <(nl File-Reference)
should work.
Update: answering the comment below:
diff --old-line-format '%L' \
--new-line-format '' \
--unchanged-line-format '' \
<(nl File-out) <(nl File-ref) | \
awk '{print $1 "p"}' > BUGLINEPRINTER.sed && \
sed -n -f BUGLINEPRINTER.sed File-In > File-In-bugs
Will do what you want. You can do it many other ways OTOH.
HTH
Upvotes: 1