Grep: Difference between revisions
Content added Content deleted
Line 27: | Line 27: | ||
=One-Liners= |
=One-Liners= |
||
Case insensitive search |
Case insensitive search |
||
Line 35: | Line 34: | ||
grep -iw "is" demo_file |
grep -iw "is" demo_file |
||
Display N lines after match |
Display N lines after, before, around match |
||
grep -A 3 -i "example" demo_text |
grep -A 3 -i "example" demo_text # After Match |
||
⚫ | |||
⚫ | |||
Display N lines before match |
|||
⚫ | |||
Display N lines around match |
|||
⚫ | |||
Color Filtered Output |
Color Filtered Output |
||
Line 50: | Line 45: | ||
export GREP_OPTIONS='--color=auto' GREP_COLOR='100;8' |
export GREP_OPTIONS='--color=auto' GREP_COLOR='100;8' |
||
Recursive Search |
|||
Searching in all files recursively |
|||
grep -r " |
grep -r "test" * |
||
Invert match |
Invert match |
||
Line 60: | Line 55: | ||
How many lines matches the given pattern |
How many lines matches the given pattern |
||
grep -c "go" demo_text |
grep -c "go" demo_text |
||
How many lines that does not match the pattern |
How many lines that does not match the pattern |