diff-check-txt.py
· 373 B · Python
Eredeti
file1 = "misc.txt"
file2 = "misc1.txt"
with open(file1) as f:
a = set(line.strip() for line in f)
with open(file2) as f:
b = set(line.strip() for line in f)
print("---- Lines in misc.txt but NOT in misc1.txt ----")
for x in sorted(a - b):
print(x)
print("\n---- Lines in misc1.txt but NOT in misc.txt ----")
for x in sorted(b - a):
print(x)
hwc@arch ~/m
| 1 | file1 = "misc.txt" |
| 2 | file2 = "misc1.txt" |
| 3 | |
| 4 | with open(file1) as f: |
| 5 | a = set(line.strip() for line in f) |
| 6 | |
| 7 | with open(file2) as f: |
| 8 | b = set(line.strip() for line in f) |
| 9 | |
| 10 | print("---- Lines in misc.txt but NOT in misc1.txt ----") |
| 11 | for x in sorted(a - b): |
| 12 | print(x) |
| 13 | |
| 14 | print("\n---- Lines in misc1.txt but NOT in misc.txt ----") |
| 15 | for x in sorted(b - a): |
| 16 | print(x) |
| 17 | hwc@arch ~/m |