grep
Basic Syntax
grep [options] pattern [file...]Option Examples
Option
Example
Description
grep Regular Expressions
Wildcards
Quantifiers
POSIX Character Classes
Character Ranges
Positions
Most Useful grep Commands
grep Commands1. Find a Specific Keyword
2. Case-Insensitive Search
3. Recursive Search
4. Show Line Numbers
5. Show Lines Before/After/Context
6. Multiple Keywords (OR Search)
7. Invert Match
8. Count Occurrences
9. Search Whole Words
10. Live Log Monitoring
Save Results to a File
Piping with grep
grepBasic Syntax
Common Piping Examples
1. Filter dmesg Logs for USB Events
dmesg Logs for USB Events2. Find Running Processes
3. Combine with tail for Real-Time Monitoring
tail for Real-Time Monitoring4. Chain Multiple Pipes
5. Use with ls to Search for Files
ls to Search for FilesQuick Tip: Grep Output Colors
Resources for Practicing
grep Cheatsheet

Last updated