Grep: Difference between revisions

Content added Content deleted
 
Line 47: Line 47:
Recursive Search
Recursive Search
grep -r "test" *
grep -r "test" *

Recursively but ignore binary files
grep -rI "test" someDir/


Invert match
Invert match
Line 92: Line 95:
Grep from compressed files
Grep from compressed files
zgrep -I "free space" ./messages*
zgrep -I "free space" ./messages*

Print lines which begin with "foo" and end in "bar"
grep "^foo.*bar$" file.txt

Filter the Filtered output:
grep "test" file.txt | grep -v "pass"

Search for the string and not the regex:
fgrep "foobar" file.txt
grep -F "foobar" file.txt


<br />
<br />