Linux Commands Reference - Complete Linux Command Guide

Comprehensive Linux command reference with 150+ commands. Search, filter by category, and view detailed usage examples.

Share
Back to commands

grep

Global regular expression search

Syntax

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

Common Options

-iIgnore case distinctions
-vInvert match
-nPrefix line numbers
-rRecursive search
-lShow only filenames
-cShow only match counts
-wMatch whole words only
-EUse extended regex

Common Examples

grep "pattern" file.txt

Search pattern in file

grep -r "pattern" /path/

Recursive directory search

grep -i "pattern" file.txt

Case-insensitive search

grep -v "pattern" file.txt

Show non-matching lines

Related Commands

Related Tools

More Code & Dev Tools