Sujet : Re: Configuration d'un super PC Linux pour Ghost "Michu" Raider - questions sur le langage de commande
De : lhh+news-no_spam (at) *nospam* free.fr.isnt.invalid (Jacques L'helgoualc'h)
Groupes : fr.comp.os.linux.configurationDate : 12. Apr 2022, 12:36:51
Autres entêtes
Organisation : Aucune.
Message-ID : <slrnt5ali3.51a.lhh+news-no_spam@hercule.home.arpa>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
User-Agent : slrn/1.0.3 (Linux)
Le 12-04-2022, Ghost-Raider a écrit :
[...]
- la commande grep permet-elle l'utilisation des opérateurs logiques :
AND, OR, XOR ?
Grep utilise les expressions régulières, OR est facile :
grep 'GR\|PC' fichier.txt
mais pour AND, c'est plus tordu :
grep -E 'GR.*PC|PC.*GR'
et il y a six cas pour le double AND.
a XOR b = ( a AND NOT b ) OR ( NOT a AND b ) # l'un mais pas l'autre
= ( a OR b ) AND NOT ( a AND b ) # ou mais pas et
c'est déjà moche --- grep offre l'option négative -v, mais il faudra
cascader deux grep.
Il y a Awk, ... mais Sed peut le faire, de manière plutôt illisible ;)