Documente Academic
Documente Profesional
Documente Cultură
grep
How it works?
grep examples
grep Pattern
grep Pattern filename
$? is set to 0
$? is set to 1
$? is set to 2
grep continue
grep re *
grep pattern
More examples
A=This is it
echo $A | grep This
A=`grep tborrelli /etc/passwd`
if [[ -z $A ]] ; then
echo tborrelli Not found
else
echo tborrelli found
fi
grep Options
grep
-i: ignore case
grep v # /etc/hosts
-c: Print the number of lines where the pattern was found
Pqops.c
Pqops.h
Scheduler.c
grep
egrep (grep E)
fgrep (grep F)
grep ^[0-9][0-9]*$
Try grep ^[0-9]+$
Try grep ^[0-9]\+$
Recursive grep
fgrep
egrep
egrep
Metacharacter
+, ?, a|b, ( )
NW|EA datafile
egrep 3+ datafile
egrep 2\.?[0-9] datefile
egrep (no)+ datafile
egrep S(h|u) datafile
egrep Sh|u datafile
egrep [[:space:]]\.[[:digit:]][[:space:]] datafile
egrep (Cont)
egrep ^$ file
egrep fun\.$ file
egrep [A-Z][0-9] file
egrep v [tT]est file
egrep i sam file
egrep l Dear Boss *
egrep n $name file
GNU grep
grep
egrep or grep E
fgrep or grep F
More metacharacters
\w same as [a-zA-Z0-9_]
\W same as [^a-zA-Z0-9_]