I have two binary files.
One of few hundreds kilos and other of few gigabytes.
I want to know whether the whole, smaller, file is contained within the larger one and if so then what is the offset from the start of the larger file.
I am interested only in exact matches i.e. whether the whole file is contained by the another.
Both files are binary.
Is there any existing tool/one-liner that does that ?
|
|
|||
|
|
I could not come up with an existing tool.
But it is a few liner in a programming language with a decent library. For example as a C++ program using Boost:
You can compile it like this (when the program source is saved as
To test it:
The output is the matching position in the source file. If the file is not contained the exit status is |
|||||||||||
|
|
Here's a Python script that performs a substring search on an external file. The script was originally written by Kamran Khan and posted to his blog. I very slightly adapted it to take the search string from a file and search in standard input.
|
|||
|
|