Search for a string in binary files
Grant Edwards
grante at visi.com
Tue Jul 22 10:47:31 EDT 2003
In article <bfjf6d$1f3$1 at solaris.cc.vt.edu>, hokieghal99 wrote:
> 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?
Of course. How could it search a file without opening it?
> And, would it be more efficent (faster) to just call grep from
> python to do the searching?
Perhaps. Depends on the size/number of the files.
--
Grant Edwards grante Yow! I want another
at RE-WRITE on my CEASAR
visi.com SALAD!!
More information about the Python-list
mailing list