python
5 years, 1 month ago
import os
search_path = input("Enter directory path to search : ")
file_type = input("File Type : ")
search_str = input("Enter the search string : ")
if not (search_path.endswith("/") or search_path.endswith("\\") ):
search_path = search_path + "/"
f= open("elbaccesslog.txt","w+")
for fname in os.listdir(path=search_path):
if fname.endswith(file_type):
fo = open(search_path + fname)
line = fo.readline()
line_no = 1
while line != '' :
index = line.find(search_str)
if ( index != -1) :
print(line)
f.write( line)
line = fo.readline()
line_no += 1
fo.close()
0 Comments
Please Login to Comment Here