[grep] Search a binary file as text with grep -a

Created on November 30, 2026

Pass -a to process input as text even when grep detects binary data. This example creates a file with a NUL byte and prints the portion matching world.

printf 'hello\0world\n' > sample.bin
grep -a -o 'world' sample.bin
world
Shell command