Grep doesn’t give the correct offset

terminalunix

Trying to get the bytes offset of a text word in a binary file (with some text here and there). I need to know the offset of this word from the beginning of the file. I'm wondering if on osx the command options are slightly different from other unix.

strings Agent_of_Change.mobi | grep -o -b --binary EXTH

This gives me : 31:EXTH

Not sure what 31 is, the bytes from the beginning of the line? The correct value I need would be 1617, from the beginning of the file.

Best Answer

Grep is likely counting the offset from the output of the strings command since it's not actually parsing the .mobi file directly.