grep searches files for text.

Basic Syntax

grep [options] <text> <file pattern>

Flags

Flag Description
-r Recursively searches files specified in the directory as the <file pattern> argument
-R Like -r but follows symbolic links
-i Ignore case
-n, –line-number Display line numbers

Examples

Recursive, case-insensitive search of the current directy for the word “todo”, displaying line numbers:

grep -rin todo .