-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /bin/sh | ||
# binary-grep.sh | ||
# find offset of one binary file inside another binary file | ||
# license: public domain | ||
# https://unix.stackexchange.com/questions/39728 | ||
|
||
if [ $# != 2 ]; then | ||
echo "usage: $0 needle.bin haystack.bin" >&2 | ||
exit 1 | ||
fi | ||
|
||
needle="$1" | ||
haystack="$2" | ||
|
||
# the order of the files $haystack and $needle | ||
# matters for performance | ||
|
||
xdelta3 -e -s "$haystack" "$needle" /dev/stdout | | ||
xdelta3 printhdrs /dev/stdin | | ||
grep "VCDIFF copy window offset" | cut -c 31- |