I'm new to python and not looking for the "fast way" but for a hint.
I want to check a file for the pattern "error: " and print it with the line number so that I later on know where to look. If however the value is 0 (means "error: 0") this should not trigger.
Here's my "match all error:" script:
#!/usr/bin/env python
import re
import sys
lookup = 'errors: '
lookup2 = 'errors: 0'
with open(sys.argv[1]) as myFile:
for num, line in enumerate(myFile, 1):
if lookup in line:
print('Line:', num, line)
I tried the "not" statament but this doesn't work:
#!/usr/bin/env python
import re
import sys
lookup = 'errors: '
lookup2 = 'errors: 0'
with open(sys.argv[1]) as myFile:
for num, line in enumerate(myFile, 1):
if lookup in line not lookup2:
print('Line:', num, line)
Any hints? Sorry for my probably very basic question...