grep

Recherche en ignorant la casse :

grep -i foo /fichier

Recherche de manière récursive :

grep -r foo /fichier

Recherche le terme exact (en début ou fin de ligne, ou entouré de ponctuations)

grep -w foo /fichier

Afficher 1 ligne après l'occurance :

grep -A1 foo /fichier

Afficher 1 ligne avant l'occurance :

grep -B1 foo /fichier

grep avec des expressions régulières

Chercher plusieurs expressions :

grep -E 'foo|bar' /fichier

Chercher une ligne qui commence par l'expression “foo” :

grep ^foo /fichier

Chercher une ligne qui se termine par l'expression “foo” :

grep foo$ /fichier

Chercher une ligne qui ne contient que “foo”

grep ^foo$ /fichier

Chercher des lignes vides :

grep '^$' /fichier