Blog › Linux · Published 2026-11-26

Find all files containing a specific text on Linux with grep

The standard tool is grep. To search every file under a folder:

grep -rn "some text" /path/to/folder

List only file names

grep -rl "some text" .

Only some file types

grep -rn --include="*.php" "some text" .

Skip a folder

grep -rn --exclude-dir=node_modules "some text" .

Quote the text so the shell does not change it. Binary files can be skipped with -I.

Official sources

Need help with your project?
We build websites, systems and automation. Start your project WhatsApp

All articles