Contents |
find all lines NOT containing 'svin' (in[V]erted matching):
$ egrep -v svin
show [O]nly matching parts:
$ egrep -o svin
search for phone number in mails:
$ egrep -hC2 "^[0-9]{8}" ~/.maildir/cur/*
-h : don't show filenames
-C2: show 2 lines before and after matched lines (Context)
list all files in current dir and subdirs with IP numbers in them:
$ egrep -rH "(([0-9]{1,3})\.){3}\2" .|less
show match with fancy colouring:
$ egrep --color something
egrep uses POSIX 1003.2 regular expressions.
$ egrep "(svine|grise)hund"
grep uses obsolete regular expressions, which are like POSIX 1003.2 regular expressions, except that ( ) | ? + { } are escaped.
standard regex metacharacters:
. * [ ] \? \+ \{ \| \( \)
word matching:
$ grep "\(svine\|grise\)hund"