Changes

Jump to navigation Jump to search
no edit summary
Line 42: Line 42:  
  grep -rnw '/path/' -e "pattern"
 
  grep -rnw '/path/' -e "pattern"
   −
* r or -R is recursive,
+
* -r or -R is recursive,
* n is line number, and
+
* -n is line number, and
* w stands match the whole word.
+
* -w stands match the whole word.
* l (lower-case L) can be added to just give the file name of matching files.
+
* -l (lower-case L) can be added to just give the file name of matching files.
 
  --exclude or --include parameter could be used for efficient searching. Something like below:
 
  --exclude or --include parameter could be used for efficient searching. Something like below:
 
  grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
 
  grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
 
  grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
 
  grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
 
  grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
 
  grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"

Navigation menu