Is there a Linux command-line tool (like grep) that can take a binary file and a series of bytes and return the first index where these bytes appear in the file?
Asked
Active
Viewed 7,120 times
2 Answers
2
$ grep --only-matching --byte-offset --max-count=1 --text --perl-regexp "\xefa" pathtofile
22157929:ïa
Outputs offset in bytes (start with 0) along with found text, e.g. \xefa
searchs for byte with hex code xe
followed by char a
, --max-count
how many occurrences to find. Works on my Linux Mint.

Martian2020
- 307
- 3
- 12
0
You can use xxd
to create a hexdump of the binary files and search that.

Amir Afghani
- 37,814
- 16
- 84
- 124
-
Not exactly what I was looking for, but the comment by @Dan Fego did the job :-) – Eldad Mor Jan 06 '12 at 23:45