(4 réponses)
Fermé il y a 7 ans.
J'utilise la commande suivante pour rechercher des fichiers avec une chaîne donnée :
find /var/www/http -type f | xargs grep -iR "STRING1"
Mais comment puis-je trouver des fichiers contenant "STRING1" OU "STRING2" OU "STRING3" ?
Ce code ne fonctionne pas :
find /var/www/http -type f | xargs grep -iR "STRING1" | xargs grep -iR "STRING2"
Réponse acceptée :
POSIXly, en utilisant grep
avec -E
choix :
find /var/www/http -type f -exec grep -iE 'STRING1|STRING2' /dev/null {} +
Ou -e
:
find /var/www/http -type f -exec grep -i -e 'STRING' -e 'STRING2' /dev/null {} +
Avec certaines implémentations, au moins sur les systèmes GNU, OSX et FreeBSD, vous pouvez échapper |
:
find /var/www/http -type f -exec grep -i 'STRING1\|STRING2' /dev/null {} +