Aller au contenu

« Grep » : différence entre les versions

De Marmits Wiki
Aucun résumé des modifications
Aucun résumé des modifications
 
(Une version intermédiaire par le même utilisateur non affichée)
Ligne 1 : Ligne 1 :
== classique ==
== classique ==
grep -Rl "{{skin url" * ou grep -Rl "{{skin url" /rep
<syntaxhighlight lang="bash" line copy>
 
grep -Rl "{{skin url" * ou grep -Rl "{{skin url" /rep
</syntaxhighlight>
== exclure un repertoire ==
== exclure un repertoire ==
grep -Rl "quetchose" * | grep -v '^unrepertoire/'
<syntaxhighlight lang="bash" line>
grep -Rl "fwrite" * | grep -v '^unrepertoire/' | grep -v '^unautrerepertoire/'
grep -Rl "quetchose" * | grep -v '^unrepertoire/'
grep "Googlebot" > Googlebot.txt
grep -Rl "fwrite" * | grep -v '^unrepertoire/' | grep -v '^unautrerepertoire/'
 
grep "Googlebot" > Googlebot.txt
</syntaxhighlight>
== résultats détaillés ==
== résultats détaillés ==
=== affiche les fichiers triés par date précédés du nom du répertoire ===
=== affiche les fichiers triés par date précédés du nom du répertoire ===
  ls -lRt | egrep '^\.|*'
<syntaxhighlight lang="bash" line copy>
ls -lRt | egrep '^\.|*'
</syntaxhighlight>
 
=== Chercher plusieurs termes avec grep -E (regex étendue) ===
<syntaxhighlight lang="bash" line copy>
history | grep -E 'ssh|docker|composer'
</syntaxhighlight>
 
=== Chercher plusieurs termes présents sur la même ligne avec grep + grep ===
<syntaxhighlight lang="bash" line copy>
history | grep 'docker' | grep 'build'
</syntaxhighlight>


=== Ignorer la casse (majuscules/minuscules) ===
<syntaxhighlight lang="bash" line copy>
history | grep -iE 'git|composer'
</syntaxhighlight>
[[category:Linux]]
[[category:Linux]]

Dernière version du 3 juin 2025 à 08:41

classique

grep -Rl "{{skin url" * ou grep -Rl "{{skin url" /rep

exclure un repertoire

grep -Rl "quetchose" * | grep -v '^unrepertoire/'
grep -Rl "fwrite" * | grep -v '^unrepertoire/' | grep -v '^unautrerepertoire/'
grep "Googlebot" > Googlebot.txt

résultats détaillés

affiche les fichiers triés par date précédés du nom du répertoire

 ls -lRt | egrep '^\.|*'

Chercher plusieurs termes avec grep -E (regex étendue)

history | grep -E 'ssh|docker|composer'

Chercher plusieurs termes présents sur la même ligne avec grep + grep

history | grep 'docker' | grep 'build'

Ignorer la casse (majuscules/minuscules)

history | grep -iE 'git|composer'