Skip to main content
2 of 3
convert to python3 now that python 2 is eol.
Stéphane Chazelas
  • 584.9k
  • 96
  • 1.1k
  • 1.7k

If those file contents are called file1, file2 and file3 in order of appearance and are properly UTF-8 encoded text, then you can do it with the following one-liner:

 # python3 -c "x=open('file1').read(); y=open('file2').read(); print(x in y or y in x)"
 True
 # python3 -c "x=open('file2').read(); y=open('file1').read(); print(x in y or y in x)"
 True
 # python3 -c "x=open('file1').read(); y=open('file3').read(); print(x in y or y in x)"
 False
Timo
  • 6.5k
  • 1
  • 28
  • 30