I'm building a little program that reads every line in a log file and if it finds a match it prints that line. The problem is, I have about 20 different log files and they all in the same folder. Is there a way I can parse through every single log file in a folder and print out the line that matches the searched word? Below is an example of what I have so far, but it prints nothing. The script needs to be able to incorporate readlines() and split()
What I have below doesn't work, but this is what I would expect it to look like. Any advice welcome.
def Preview():
path = ('C:Users/kev/Desktop/test/*.log')
files = glob.glob(path)
files.readlines()
for line in files:
if "test_word" in line:
print line
Preview()