thanks, the 'grep -b' option only works if the input is considered to be text and in my case it is binary and grep only want to say "match/not match"

Anyway, it seems to be pretty easy in perl so I went that route.