Skip to content

Commit

Permalink
add binary-grep.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
milahu committed Mar 30, 2023
1 parent 952ea77 commit d2881ee
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bash/binary-grep.sh
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-

0 comments on commit d2881ee

Please sign in to comment.