Skip to content
SimpleConvertSimpleConvert

Linux grep Command

Searching files with grep: the flags worth knowing by heart, recursive searching, and how to stop it choking on binary files and huge trees.

Formula
grep [OPTION]... PATTERN [FILE]...

How to use it

  • The synopsis at the top shows the general form of the command.
  • Click any example to copy it straight to your clipboard.
  • The options table lists only the flags worth remembering — run man for the exhaustive list.

Examples

grep -i error app.logcase-insensitive search in one file
grep -rn TODO src/search a tree, showing line numbers
grep -c warning app.logcount matching lines

Questions people ask

How do I search for a literal dot or bracket?

Escape it with a backslash, or use grep -F, which treats the pattern as a fixed string with no special characters at all.

Why is grep skipping some files?

It detects binary content and reports a match without printing it. Add -a to treat everything as text, or --include to restrict the search to the file types you care about.

Does this page work offline?

Yes, after the first visit. The whole reference is part of the page and the service worker caches it.

Runs entirely in your browser. Nothing you type is uploaded, logged or shared.

Last updated 22 August 2026