Ray's Knowledge Base
Unlock

ugrep skips binary files by default, so grep on a .dylib or .so proves nothing

PitfallVerified 2 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

grep -q "text" lib.dylib (or *.so) finds nothing, so a search for a stale string in a built binary looks negative.

Cause#

The shell's grep on this machine is ugrep, which skips binary files by default. The empty result says nothing about the file.

Fix#

Search binaries with /usr/bin/grep -a "text" file. First confirm the search works by looking for a string you know is in the file.

Evidence#

A stale-binary hunt in dftracer-utils that relied on plain grep was inconclusive.

Also found by searching

  • grep -q "text" lib.dylib finds nothing
  • grep does not find a string in a .so or .dylib file
  • how do I search a binary file for a string when grep is ugrep
  • stale binary hunt with grep was inconclusive