Created
March 25, 2016 10:26
-
-
Save rririanto/5dc790aac90e4656331d to your computer and use it in GitHub Desktop.
Python Small Script to find text string in files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
@jimmyromanticde | |
Problem | |
Find or Search text string in files | |
''' | |
DIRFOLDER = '/home/romanticdevil/myworkspace/Dj1.4/project/newversion1.0/titik_tanya' | |
import os, re | |
text = raw_input('string search: ') | |
datas = [] | |
for i, j, k in os.walk(DIRFOLDER): | |
for x in k: | |
try: | |
for data in open(i+'/'+x,'r').readlines(): | |
if re.search(text, data): | |
datas.append(os.path.join(i, x)) | |
except: | |
continue | |
datas = set(datas) | |
for i in datas: | |
print "Found on path: %s"%i | |
b = raw_input('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment