Syntax
Description
Thegrep command searches for lines containing a specified pattern. It reads from files or standard input and outputs only matching lines. This is one of the most powerful text filtering tools in Unix-like systems.
Nash’s grep performs substring matching (not regex) and operates entirely within the virtual filesystem.
Options
The text pattern to search for. Performs literal substring matching.
Invert match. Show lines that do NOT contain the pattern.Alias:
--invert-matchIgnore case distinctions. Makes the search case-insensitive.Alias:
--ignore-casePrefix each output line with its line number.Alias:
--line-numberExamples
Basic pattern search
Case-insensitive search
Invert match
Show line numbers
Search in files
Combine flags
Pipeline Examples
Filter process output
Multi-stage filtering
.txt files but excludes those with “test” in the name.
Count matches
Extract specific records
Practical Use Cases
Log analysis
Configuration validation
Filter file listings
Quick content check
Extract data fields
Exit Status
- 0 - At least one match found
- 1 - No matches found
Nash’s
grep uses substring matching, not regular expressions. The pattern "a.b" matches the literal string “a.b”, not “a” followed by any character and “b”.Tips
Multiple patterns
Use multiplegrep commands in a pipeline:
