5 def grep(pattern
,dirname
,names
):
7 filename
= os
.path
.join(dirname
,name
)
8 if os
.path
.isfile(filename
):
9 lines
= open(filename
,"r").readlines()
11 if pattern
.search(line
):
16 def find(pattern
,directory
= "."):
17 os
.path
.walk(directory
,grep
,re
.compile(pattern
))
20 if __name__
== "__main__":
22 if len(sys
.argv
) == 2:
24 elif len(sys
.argv
) == 2:
25 find(sys
.argv
[2],sys
.argv
[1])