There are useful grep one liners taken from the blog -
http://girirajcollections.blogspot.in/2010/07/grep-one-liners.html
grep one-liners
Basics
grep case insensitive
grep -i ""
grep recursively
grep -ir ""
grep with word match only (string starting/ending with non-word constituent character)
grep -wi ""
remove/delete filename from grep output
grep -hi ""
Logical operators
grep for this OR this
grep -i "\|"
grep for this AND this
grep -i "" | grep -i ""
grep NOT for this
grep -iv ""
grep for this AND NOT this
grep -i "" | grep -iv ""
Misc
count the number of lines
grep -ic ""
grep through compressed files
zgrep -i ""
Selective Printing
print the X lines before each matching lines
grep -i "" -B
print the Y lines after each matching lines
grep -i "" -A
print the X,Y lines before and after each matching lines
grep -i "" -B -A
http://girirajcollections.blogspot.in/2010/07/grep-one-liners.html
grep one-liners
Basics
grep case insensitive
grep -i "
grep recursively
grep -ir "
grep with word match only (string starting/ending with non-word constituent character)
grep -wi "
remove/delete filename from grep output
grep -hi "
Logical operators
grep for this OR this
grep -i "
grep for this AND this
grep -i "
grep NOT for this
grep -iv "
grep for this AND NOT this
grep -i "
Misc
count the number of lines
grep -ic "
grep through compressed files
zgrep -i "
Selective Printing
print the X lines before each matching lines
grep -i "
print the Y lines after each matching lines
grep -i "
print the X,Y lines before and after each matching lines
grep -i "
Tags
Unix