Extraire une partie d'un fichier

Résolu/Fermé
Ka-El Messages postés 260 Date d'inscription lundi 28 novembre 2011 Statut Membre Dernière intervention 7 août 2020 - 5 mars 2012 à 17:51
Ka-El Messages postés 260 Date d'inscription lundi 28 novembre 2011 Statut Membre Dernière intervention 7 août 2020 - 7 mars 2012 à 08:58
Bonjour,
A partir du fichier suivant :
appli_APRLVPP_xfb1.txt appli_APRLVPP_xfb2.txt sont différents: octet 86, ligne 4
appli_APRLVPT_xfb1.txt appli_APRLVPT_xfb2.txt sont différents: octet 86, ligne 4
appli_ASORALLP_xfb1.txt appli_ASORALLP_xfb2.txt sont différents: octet 86, ligne 4
cgate_CG_TOTO_xfb1.txt cgate_CG_VEOLIAT_xfb2.txt sont différents: octet 755, ligne 29
cgate_CG_WEBNETP_xfb1.txt cgate_CG_WEBNETP_xfb2.txt sont différents: octet 832, ligne 32
cgate_HTTPS_TONTONP_xfb1.txt cgate_HTTPS_VALLOURECP_xfb2.txt sont différents: octet 706, ligne 25
cgate_HTTPS_TONTONT_xfb1.txt cgate_HTTPS_VALLOURECT_xfb2.txt sont différents: octet 706, ligne 25

j'ai besoin d'extraire les données suivantes :
APRLVPP
APRLVPT
ASORALLP
CG_TOTO
CG_WEBNETP
HTTPS_TONTONP
HTTPS_TONTONT

Pouvez-vous m'aider à effectuer cette opération ?
Merci.
A voir également:

2 réponses

zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 6 407
5 mars 2012 à 18:09
Salut,

Attention, l'exemple ci-après ne s'applique qu'à l'exemple donné ;-\

$ sed 's/[^[:upper:]_]//g;s/^_\|__.*//g' fich 
APRLVPP
APRLVPT
ASORALLP
CG_TOTO
CG_WEBNETP
HTTPS_TONTONP
HTTPS_TONTONT

;-))
0
zipe31 Messages postés 36402 Date d'inscription dimanche 7 novembre 2010 Statut Contributeur Dernière intervention 27 janvier 2021 6 407
5 mars 2012 à 18:24
Ou plus simplement :

sed 's/[^_]*_\([^ ]*\)_.*/\1/' fich

:-))
0
Ka-El Messages postés 260 Date d'inscription lundi 28 novembre 2011 Statut Membre Dernière intervention 7 août 2020
7 mars 2012 à 08:58
Bonjour et merci zipe31.
Ta seconde proposition fonctionne nickel !
Bonne journée.
0