Vous n'êtes pas identifié(e).
L'icône rouge permet de télécharger chaque page du wiki visitée au format
PDF et la grise au format ODT →
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente Prochaine révision Les deux révisions suivantes | ||
utilisateurs:hypathie:tutos:accueil [18/07/2014 10:18] Hypathie [Synthèse grep] |
utilisateurs:hypathie:tutos:accueil [18/07/2014 11:05] Hypathie [Synthèse grep] |
||
---|---|---|---|
Ligne 169: | Ligne 169: | ||
> Deux utilisations:\\ | > Deux utilisations:\\ | ||
>Soit ''grep [options] "expression" /chemin/fichier'' (on applique grep sur un fichier) | >Soit ''grep [options] "expression" /chemin/fichier'' (on applique grep sur un fichier) | ||
- | >Soit ''grep [options] cmd | regexp'' (on travaille à partir d'un flux d'entrée avec un filtre (pipe)\\ | + | >Soit ''cmd | grep [options]'' (on travaille à partir d'un flux d'entrée avec un filtre (pipe)\\ |
Ligne 181: | Ligne 181: | ||
===Filtre un flux d'entrée === | ===Filtre un flux d'entrée === | ||
+ | <code user> | ||
+ | /sbin/ifconfig | grep -E "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | ||
+ | </code> | ||
+ | <code> | ||
+ | inet adr:192.168.0.22 Bcast:192.168.0.255 Masque:255.255.255.0 | ||
+ | inet adr:127.0.0.1 Masque:255.0.0.0 | ||
+ | </code> | ||
<code user> | <code user> | ||
/sbin/ifconfig | grep -oE "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | /sbin/ifconfig | grep -oE "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | ||
Ligne 190: | Ligne 197: | ||
192.168.0.255 | 192.168.0.255 | ||
255.255.255.0 | 255.255.255.0 | ||
+ | </code> | ||
+ | |||
+ | <note tip> | ||
+ | Attention de ne pas oublier ''-o'' pour afficher l'occurrence exacte d'un mot au lieu de la ligne entière où figure l'occurrence du mot ! | ||
+ | </note> | ||
+ | <code user> | ||
+ | echo "bfer aaa jhgao aaaaaa haug aaaaaaaa" | grep -E "[[:blank:]][a]{3}[[:blank:]]" | ||
+ | </code> | ||
+ | <code> | ||
+ | bfer aaa jhgao aaaaaa haug aaaaaaaa | ||
+ | </code> | ||
+ | |||
+ | <code user> | ||
+ | echo "bfer aaa jhgao aaaaaa haug aaaaaaaa" | grep -oE "[[:blank:]][a]{3}[[:blank:]]" | ||
+ | </code> | ||
+ | <code> | ||
+ | aaa | ||
</code> | </code> | ||
=====Synthèse sed ===== | =====Synthèse sed ===== |