Skip to content
sinsunsan edited this page Dec 18, 2012 · 20 revisions

Liens

Make fuzzy search with agrep http://www.commandlinefu.com/commands/view/9778/approximate-grep-for-finding-typos

http://www.selectorweb.com/grep_tutorial.html

Cas pratiques

  • Only the files
    Retrieve only the files in which the string is found whatever the number of instance in this file
    grep -rl "my string

  • Files inside a specific dir
    grep -r "autocomplete" sites/all/modules/nodequeue

  • Exclude dir
    Chercher dans les fichiers mais pas dans les fichiers binaires (images...)
    grep -rn "petite question" * --exclude-dir='files'

  • Escape special character
    Echapper les caractère spéciaux

grep -rn "\$vars\\['comment'\]" * --exclude-dir="files"
  • Grep on the files searched by find
  • Search in a specific file
    find -type f -name *rue89block.inc* -exec grep "3 voix" {} \;

  • Search in all .install files the pattern "nodequeue" find -type f -name *.install -exec grep -rn nodequeue {} \;

  • Escape special character (here regular expression)
```grep -rn "\['options'\]\\['status'\]"```

To search ['option']['status'] typical drupal form array

WIKI by Sébastien Lucas CEO & Funder or Bricks

Clone this wiki locally