Monday, February 02, 2009

grep basics

grep 'abcd' /home/usr/ | more
grep -i 'abcd' *.c  --ignore case
grep -n 'abcd' *.c  --output line no.
grep -l 'abcd' *.c  --only list filename 
grep -w 'abcd' *.c  --match whole word
grep -r 'abcd' ./   --into subdir

grep -v             --invert match

grep [...] --[afk] [1-8]
grep [^..] --NOT
grep ^abcd --start of line
grep abcd$ --end of line

find ../ -name *core |xargs grep 'abcd'
find . -type f -name *.c -not -name "h264*" | xargs grep -RnisI --color "numPlanes"     -- search all .c file, exclude h264*.c files, for pattern.

No comments:

Post a Comment