Linux – Best way to grep big binary file

data-recoverygreplinux

What is the fastest way to grep 400gb binary file?
I need one txt file from hdd dump and i know some strings from it and want to find this file in dump.

I tried to use grep -a -C 10 searchstring but grep crashes with out of memory when it tries to read large chunk of data without newline symbols. Also i would like to start searching from not from the beginning but from some point of file

Best Answer

I would use strings that way :

strings 400Gfile.bin | grep -C 10 searchstring

To start at a given offset (eg: 20G),

dd if=400Gfile.bin bs=20G skip=1 | strings | grep -C 10 searchstring