Extraire une partie d'un fichier

Résolu
Ka-El Messages postés 279 Statut Membre -  
Ka-El Messages postés 279 Statut Membre -
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.

2 réponses

  1. zipe31 Messages postés 34620 Date d'inscription   Statut Contributeur Dernière intervention   6 501
     
    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
    1. zipe31 Messages postés 34620 Date d'inscription   Statut Contributeur Dernière intervention   6 501
       
      Ou plus simplement :

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

      :-))
      0
  2. Ka-El Messages postés 279 Statut Membre
     
    Bonjour et merci zipe31.
    Ta seconde proposition fonctionne nickel !
    Bonne journée.
    0