[ale] Binary Grep

Geoffrey esoteric at 3times25.net
Wed Nov 17 05:47:04 EST 2004


Fletch wrote:
>>>>>>"Geoffrey" == Geoffrey  <esoteric at 3times25.net> writes:
> 
> 
>     Geoffrey> Greg Freemyer wrote:
>     >> Does anyone know of a grep like tool that works for binary
>     >> files?  In particular, I have a binary file I want to find all
>     >> occurrances of 16 hex FF chars in a row.  ie.  0xFF, 0xFF,
>     >> 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
>     >> 0xFF, 0xFF, 0xFF, 0xFF It would be great if it also provided
>     >> some surrounding detail, but at a minimum I need the offset in
>     >> the file.  Thanks Greg
> 
>     Geoffrey> Man I keep getting great ideas. :) use perl?
> 
> But of course!

I figured Fletch would come through. :)

> 
> $ perl -le 'print "a" x 2048, "b" x 512, "\xff" x 16, "b" x 512' > foo
> $ perl -lne 'BEGIN{$/=\1024} print "hit byte ", ($.-1) * 1024 + $-[0] if /\xff{16}/' foo
> hit byte 2560
> $ perl -le 'print "a" x 2048, "b" x 1512, "\xff" x 16, "b" x 512' > foo
> $ perl -lne 'BEGIN{$/=\1024} print "hit byte ", ($.-1) * 1024 + $-[0] if /\xff{16}/' foo
> hit byte 3560
> 
> 


-- 
Until later, Geoffrey



More information about the Ale mailing list