Dear,
I'd like to write a script to compare many text files like attached ones for an example(actually there are many text files like:
sg_logs-sdaa-before.txt
sg_logs-sdaa-after.txt
sg_logs-sdab-before.txt
sg_logs-sdab-after.txt
sg_logs-sdac-before.txt
sg_logs-sdac-after.txt
.....ect.
And I would like the scrip to auto compare:
sg_logs-sdxx-before.txt
sg_logs-sdxx-after.txt
Plus, the number behind below strings in both text files will be compared:
attached phy identifier = x
Invalid DWORD count = x
Running disparity error count = x
Loss of DWORD synchronization = x
Phy reset problem = x
<where above x means a number>
As the attached example file, in the sg_logs-sdaa-before.txt we can see above strings presented twice:
attached phy identifier = 8
Invalid DWORD count = 259
Running disparity error count = 244
Loss of DWORD synchronization = 50
Phy reset problem = 0
attached phy identifier = 16
Invalid DWORD count = 60
Running disparity error count = 53
Loss of DWORD synchronization = 14
Phy reset problem = 0
And in another attached example text file, there is also contents below strings:
attached phy identifier = 8
Invalid DWORD count = 259
Running disparity error count = 244
Loss of DWORD synchronization = 52
Phy reset problem = 0
attached phy identifier = 16
Invalid DWORD count = 60
Running disparity error count = 53
Loss of DWORD synchronization = 14
Phy reset problem = 1
So I would like the script to compare above strings(means to compare the number behind each strings one by one between two files), like below:
<compare>
attached phy identifier = 8 (from sg_logs-sdaa-before.txt)
attached phy identifier = 8 (from sg_logs-sdaa-after.txt)
Invalid DWORD count = 259 (from sg_logs-sdaa-before.txt)
Invalid DWORD count = 259 (from sg_logs-sdaa-after.txt)
Running disparity error count = 244 (from sg_logs-sdaa-before.txt)
Running disparity error count = 244 (from sg_logs-sdaa-after.txt)
Loss of DWORD synchronization = 50 (from sg_logs-sdaa-before.txt)
Loss of DWORD synchronization = 52 (from sg_logs-sdaa-after.txt)
Phy reset problem = 0 (from sg_logs-sdaa-before.txt)
Phy reset problem = 0 (from sg_logs-sdaa-after.txt)
......ect.
And the scrip will detect that the number behind string "Loss of DWORD synchronization" between two text files is different, and then export to "report.txt" to highlight the difference with the two file names like:
Different contents:
sg_logs-sdaa-before.txt
sg_logs-sdaa-after.txt
...etc.
It is to let me know which files get different content of below strings to let me save the time to check all files one by one, so may I get help from you to create a simple script for above needed?
1. Compare multiple files with specific file name
2. Compare specific strings with might in different lines between two files
Your help is highly appreciated!
Thanks,
Jacky
I'd like to write a script to compare many text files like attached ones for an example(actually there are many text files like:
sg_logs-sdaa-before.txt
sg_logs-sdaa-after.txt
sg_logs-sdab-before.txt
sg_logs-sdab-after.txt
sg_logs-sdac-before.txt
sg_logs-sdac-after.txt
.....ect.
And I would like the scrip to auto compare:
sg_logs-sdxx-before.txt
sg_logs-sdxx-after.txt
Plus, the number behind below strings in both text files will be compared:
attached phy identifier = x
Invalid DWORD count = x
Running disparity error count = x
Loss of DWORD synchronization = x
Phy reset problem = x
<where above x means a number>
As the attached example file, in the sg_logs-sdaa-before.txt we can see above strings presented twice:
attached phy identifier = 8
Invalid DWORD count = 259
Running disparity error count = 244
Loss of DWORD synchronization = 50
Phy reset problem = 0
attached phy identifier = 16
Invalid DWORD count = 60
Running disparity error count = 53
Loss of DWORD synchronization = 14
Phy reset problem = 0
And in another attached example text file, there is also contents below strings:
attached phy identifier = 8
Invalid DWORD count = 259
Running disparity error count = 244
Loss of DWORD synchronization = 52
Phy reset problem = 0
attached phy identifier = 16
Invalid DWORD count = 60
Running disparity error count = 53
Loss of DWORD synchronization = 14
Phy reset problem = 1
So I would like the script to compare above strings(means to compare the number behind each strings one by one between two files), like below:
<compare>
attached phy identifier = 8 (from sg_logs-sdaa-before.txt)
attached phy identifier = 8 (from sg_logs-sdaa-after.txt)
Invalid DWORD count = 259 (from sg_logs-sdaa-before.txt)
Invalid DWORD count = 259 (from sg_logs-sdaa-after.txt)
Running disparity error count = 244 (from sg_logs-sdaa-before.txt)
Running disparity error count = 244 (from sg_logs-sdaa-after.txt)
Loss of DWORD synchronization = 50 (from sg_logs-sdaa-before.txt)
Loss of DWORD synchronization = 52 (from sg_logs-sdaa-after.txt)
Phy reset problem = 0 (from sg_logs-sdaa-before.txt)
Phy reset problem = 0 (from sg_logs-sdaa-after.txt)
......ect.
And the scrip will detect that the number behind string "Loss of DWORD synchronization" between two text files is different, and then export to "report.txt" to highlight the difference with the two file names like:
Different contents:
sg_logs-sdaa-before.txt
sg_logs-sdaa-after.txt
...etc.
It is to let me know which files get different content of below strings to let me save the time to check all files one by one, so may I get help from you to create a simple script for above needed?
1. Compare multiple files with specific file name
2. Compare specific strings with might in different lines between two files
Your help is highly appreciated!
Thanks,
Jacky
Comment