I've an example.txt which contains hexadecimal data like this.
09 06 07 04 00 00 01 00 1d 03 4b 2c a1 2a 02 01
b7 09 01 47 30 12 a0 0a 80 08 33 04 03 92 22 14
07 f0 a1 0b 80 00 81 00 84 01 00 86 00 85 00 83
07 91 94 71 06 00 07 19
09 06 07 04 r0 00 01 00 1d 03 4b 2c a1 2a 02 01
b7 09 01 47 30 1s a0 0a 80 08 33 04 03 92 22 14
07 f0 a1 0b 80 00 81 0d 84 01 00 86 00 85 00 83
07 91 94 71 06
09 06 07 04 r0 00 01 00 1d 03 4b 2c a1 2a 02 01
b7 09 01 47 30 1s a0 0a 80 08 33 04 03 92 22 14
07 f0 a1 0b 80 00 81 0d 84 01 00 86 00 85 00 83
b7 09 01 47 30 1s a0 0a 80 08 33 04 03 92 22 14
b7 09 01 47 30 1s a0 0a 80 08 33 04 03 92 22 14
07 f0 a1 0b 80 00 81 0d 84 01 00 86 00 85
What I want to do is to look for a specific string and if exits continue at that point looking for another string and so on. Once I know that patterns exits then I want to remove a file and if that pattern doesn´t exits remove another.
My code is this:
import os
with open('example.txt') as file:
if '12' in file.read():
if ('80' or '25' or 'a6' or '1b') in file.read():
if '04' in file.read():
if '07' in file.read():
command1 = 'rm -f file2.json'
os.system(command1)
else:
command2 = 'rm -f file1.json'
os.system(command2)