DELAPARRA
Index
Color
NL
Category: CLI commands

grep

Explained by Updated

What is grep?

grep: Global Regular Expression Print — Search for a pattern inside files or command output. grep searches for text or patterns in files and command output. grep -r "TODO" src/ finds every TODO under src, and grep -i error app.log finds error lines regardless of case. Useful options include -n for line numbers, -v to show lines that do not match, -c to count matches, -l to list only file names, and -C 3 to show three lines of context around each match.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about grep

What should you keep in mind with grep?

It shines in pipelines. docker logs web | grep -i exception filters a container's output, and ps aux | grep php finds running PHP processes. For searching large codebases, ripgrep (rg) is a faster modern alternative that respects .gitignore by default. Both are worth having in your fingers, because they work on every server you will log into.

At a glance

CategoryCLI commands
Explained by
Updated

More CLI commands terms

All terms starting with G

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.