Terminal Dojo
Help العربية Sign inGet started

Command library / grep

grep

BashDraft — pending expert review5 practice missions

Search text for lines that match a pattern

Prints the lines of a file (or of piped input) that match a pattern. It is the analyst's workhorse for logs: filter first, then count, sort or investigate. Quote patterns that contain spaces or special characters, otherwise the shell splits them into separate arguments.

Practice grep

Usage

grep [options] pattern [file...]

Options and flags

Examples

Common mistakes

grep Failed password /var/log/auth.log grep 'Failed password' /var/log/auth.log

Without quotes the shell passes 'password' as a FILE name. Quote multi-word patterns.

Related commands

lsfind