Grep: Difference between revisions
→One-Liners
Line 27:
=One-Liners=
Case insensitive search
Line 35 ⟶ 34:
grep -iw "is" demo_file
Display N lines after, before, around match
grep -A 3 -i "example" demo_text # After Match
grep -B 2 "single WORD" demo_text # Before Match▼
grep -C 2 "Example" demo_text # Around Match▼
▲ grep -B 2 "single WORD" demo_text
▲ grep -C 2 "Example" demo_text
Color Filtered Output
Line 50 ⟶ 45:
export GREP_OPTIONS='--color=auto' GREP_COLOR='100;8'
Recursive Search
grep -r "
Invert match
Line 60 ⟶ 55:
How many lines matches the given pattern
grep -c "go" demo_text
How many lines that does not match the pattern
|