Search for a string in binary files

hokieghal99 hokiegal99 at hotmail.com
Tue Jul 22 09:45:49 EDT 2003


François Pinard wrote:
> import glob
> for name in glob.glob('*.xls'):
>     if file(name, 'rb').read().find('Microsoft Excel') >= 0:
>         print "Found in", name
> 

Thanks for the example guys. One last question: does grep actually open 
files when it searches them? And, would it be more efficent (faster) to 
just call grep from python to do the searching?





More information about the Python-list mailing list