Find Text in Directory ?

How to find variable string or integer in a directory ?

consider the sample below :

import glob
import os
os.chdir( "/home/ALFIN/" )
for files in glob.glob( "*" ):
    f = open( files, 'r' )
    file_contents = f.read()
    if "DARAH MUDA" in file_contents:
            print(f.name)
    f.close()

good luck !

mm

Alfin F

Technopreneur , Developer, Advisor

More Posts

Follow Me:
TwitterLinkedIn