[NTLUG:Discuss] scratching head

kbrannen@gte.net kbrannen at gte.net
Fri Feb 28 10:55:03 CST 2003


Fred James wrote:
> Steve Baker wrote:

>>>>  find . -type f | xargs file | grep -i text | cut -f1 -d: | xargs 
>>>> grep "..."
>>>
>>>
>>
>> ...and if that's what it does, it's got a bug in it.  Suppose I have 
>> file called:
>>
>>    texture_map.png
>>
>> ...well, let's just say it's not going to be a pretty sight!
>>

> OK - problem seen - but short of writing a program what would you 
> suggest to get around it?
> 

When I do this, I make the last grep to be "grep -l".  That gives me the file 
names with the matching text to allow me to visually scan which ones to 
further persue with just a plan grep or with vi.  That doesn't totally answer 
your question, but it may get you closer. :-)

BTW, while I agree with Steve's point (data files with enough ASCII may be 
shown to be "text"), he picked a bad example.  A file that's really a PNG file 
would not be returned anyway.  Grabbing one at random off my system, the file 
command says:

./star.png:         PNG image data, 15 x 13, 2-bit colormap, non-interlaced

so the first grep would ignore it.  (sorry to be picky :-)

HTH,
Kevin




More information about the Discuss mailing list