IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Shell et commandes POSIX Discussion :

Analyse des dernières lignes d'un fichier log avec recherche de pattern sur un champ précis


Sujet :

Shell et commandes POSIX

  1. #1
    Membre à l'essai
    Homme Profil pro
    Technicien réseau
    Inscrit en
    Février 2016
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : Technicien réseau

    Informations forums :
    Inscription : Février 2016
    Messages : 21
    Points : 20
    Points
    20
    Par défaut Analyse des dernières lignes d'un fichier log avec recherche de pattern sur un champ précis
    Bonjour,

    Je fait appel à vos services pour l'écriture d'un script (shell) qui permettra de rechercher sur les "n" dernières lignes d'un fichier un caractère sur un champ précis.

    Le fichier à analyser se compose de la manière suivante (fichier en question qui se compose ici de 26 lignes) :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Poli-3;2017-02-09 14:55:00.350;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 1;R;0
    Poli-1;2017-02-09 14:55:00.359;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB2;KODI;Z;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;TITI;data manquante format 1;V;0
    Poli-10;2017-02-09 14:55:01.009;IP_SERVEUR;TESTREJET;TEST_VAL_INT;URB8;KODI;A;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;;;;TITI;data manquante format 1;U;1
    Poli-3;2017-02-09 14:56:00.350;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 1;R;0
    Poli-1;2017-02-09 14:56:00.359;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB2;KODI;Z;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;TITI;data manquante format 1;V;0
    Poli-10;2017-02-09 14:56:01.009;IP_SERVEUR;TESTREJET;TEST_VAL_INT;URB8;KODI;A;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;;;;TITI;data manquante format 1;U;1
    Poli-2;2017-02-09 14:56:01.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;R;10
    Poli-0;2017-02-09 14:56:02.150;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB5;KODI;D;;KO_TEMP;cache;AV5;proz-proe-ticket1;COSA;;;proa-noticket-proa;2016-06-12 14:33:02.389;;;;data OK format 8;;51
    Poli-2;2017-02-09 14:56:02.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;R;10
    Poli-4;2017-02-09 14:56:02.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-3;2017-02-09 14:56:02.650;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-3;2017-02-09 14:56:03.350;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 1;R;0
    Poli-1;2017-02-09 14:56:03.359;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB2;KODI;Z;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;TITI;data manquante format 1;V;0
    Poli-10;2017-02-09 14:56:04.009;IP_SERVEUR;TESTREJET;TEST_VAL_INT;URB8;KODI;A;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;;;;TITI;data manquante format 1;U;1
    Poli-2;2017-02-09 14:56:04.050;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;R;10
    Poli-0;2017-02-09 14:56:04.150;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB5;KODI;D;;KO_TEMP;cache;AV5;proz-proe-ticket1;COSA;;;proa-noticket-proa;2016-06-12 14:33:02.389;;;;data OK format 8;;51
    Poli-2;2017-02-09 14:56:05.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;;10
    Poli-4;2017-02-09 14:56:05.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-3;2017-02-09 14:56:06.050;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-0;2017-02-09 14:56:06.150;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB5;KODI;D;;KO_TEMP;cache;AV5;proz-proe-ticket1;COSA;;;proa-noticket-proa;2016-06-12 14:33:02.389;;;;data OK format 8;;51
    Poli-2;2017-02-09 14:56:07.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-4;2017-02-09 14:56:08.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-3;2017-02-09 14:56:08.650;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-1;2017-02-09 14:56:08.850;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;10
    Poli-9;2017-02-09 14:56:09.650;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10


    La où je pêche , c'est dans l'analyse de la ligne.

    L'objectif est donc, d'analyser les "n" dernières lignes du fichier (n = paramètre donné en entrée de script - prenons en exemple 20) et de rechercher (=> comptabiliser) le caractère "R" (qui peut être en majuscule ou en minuscule) sur l'avant dernier champ de la ligne (le séparateur est le ";")


    L'idée de départ était de faire un tail des "n" dernières lignes et d'utiliser soit le awk ou le sed pour analyser la ligne...
    C'est là que ça se complique.


    Résultat attendu :
    --------------------
    Nous comptabilisons en tout sur les 26 lignes du fichiers 7 fois le pattern "r" ou "R" sur l'avant dernier champs.
    Nous souhaitons comptabiliser 5 fois le pattern "r" ou "R" en recherchant sur les 20 dernières ligne du fichier (=> paramètre donné en entrée de script).



    Auriez-vous SVP une piste de départ pour analyser cette ligne ?
    Par avance merci

  2. #2
    Expert éminent sénior Avatar de frp31
    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Juillet 2006
    Messages
    5 196
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : Aéronautique - Marine - Espace - Armement

    Informations forums :
    Inscription : Juillet 2006
    Messages : 5 196
    Points : 12 262
    Points
    12 262
    Par défaut
    une methode pas super rapide mais facile a comprendre et a maintenir


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    27
    28
    29
    30
    31
    32
     
    root@h2g2:/zpool_usb_sdf# cat > toto
    Poli-3;2017-02-09 14:55:00.350;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 1;R;0
    Poli-1;2017-02-09 14:55:00.359;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB2;KODI;Z;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;TITI;data manquante format 1;V;0
    Poli-10;2017-02-09 14:55:01.009;IP_SERVEUR;TESTREJET;TEST_VAL_INT;URB8;KODI;A;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;;;;TITI;data manquante format 1;U;1
    Poli-3;2017-02-09 14:56:00.350;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 1;R;0
    Poli-1;2017-02-09 14:56:00.359;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB2;KODI;Z;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;TITI;data manquante format 1;V;0
    Poli-10;2017-02-09 14:56:01.009;IP_SERVEUR;TESTREJET;TEST_VAL_INT;URB8;KODI;A;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;;;;TITI;data manquante format 1;U;1
    Poli-2;2017-02-09 14:56:01.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;R;10
    Poli-0;2017-02-09 14:56:02.150;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB5;KODI;D;;KO_TEMP;cache;AV5;proz-proe-ticket1;COSA;;;proa-noticket-proa;2016-06-12 14:33:02.389;;;;data OK format 8;;51
    Poli-2;2017-02-09 14:56:02.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;R;10
    Poli-4;2017-02-09 14:56:02.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-3;2017-02-09 14:56:02.650;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-3;2017-02-09 14:56:03.350;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 1;R;0
    Poli-1;2017-02-09 14:56:03.359;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB2;KODI;Z;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;TITI;data manquante format 1;V;0
    Poli-10;2017-02-09 14:56:04.009;IP_SERVEUR;TESTREJET;TEST_VAL_INT;URB8;KODI;A;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;;;;TITI;data manquante format 1;U;1
    Poli-2;2017-02-09 14:56:04.050;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;R;10
    Poli-0;2017-02-09 14:56:04.150;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB5;KODI;D;;KO_TEMP;cache;AV5;proz-proe-ticket1;COSA;;;proa-noticket-proa;2016-06-12 14:33:02.389;;;;data OK format 8;;51
    Poli-2;2017-02-09 14:56:05.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;;10
    Poli-4;2017-02-09 14:56:05.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-3;2017-02-09 14:56:06.050;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-0;2017-02-09 14:56:06.150;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB5;KODI;D;;KO_TEMP;cache;AV5;proz-proe-ticket1;COSA;;;proa-noticket-proa;2016-06-12 14:33:02.389;;;;data OK format 8;;51
    Poli-2;2017-02-09 14:56:07.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-4;2017-02-09 14:56:08.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-3;2017-02-09 14:56:08.650;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-1;2017-02-09 14:56:08.850;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;10
    Poli-9;2017-02-09 14:56:09.650;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    root@h2g2:/zpool_usb_sdf# 
    root@h2g2:/zpool_usb_sdf# tail -6 toto | grep -i ";r;[0-9][0-9]$" | wc -l
    1
    root@h2g2:/zpool_usb_sdf# rm toto
    apres suffit d adapter soit a compter soit a generer en extract des lignes trouvees etc....

    par exemple paur extraire dans un fichier externe :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    root@h2g2:/zpool_usb_sdf# tail -6 toto | grep -i ";r;[0-9][0-9]$" > sortie
    root@h2g2:/zpool_usb_sdf# cat sortie
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;10
    root@h2g2:/zpool_usb_sdf#

  3. #3
    Membre à l'essai
    Homme Profil pro
    Technicien réseau
    Inscrit en
    Février 2016
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : Technicien réseau

    Informations forums :
    Inscription : Février 2016
    Messages : 21
    Points : 20
    Points
    20
    Par défaut
    Bonjour,

    Tout d'abord merci pour votre retour et de l'intérêt porté.

    En retour à votre proposition, j'aimerai porter l'accent sur le fait que le champ analyser est bien l'avant dernier.
    Je ne maîtrise la valeur des autres champs (vides ou renseignés) ainsi que le fait qu'ils soient numérique ou pas.

    Prenons m'exemple avec le cas ou le dernier n'est pas renseigné ou non numérique (1 seule ligne est remontée):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;10
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;A
     
    tail -6 toto | grep -i ";R;[0-9][0-9]$"
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;10
    Désolé de ne pas avoir été assez précis dans ma précédente explication.

    Cordialement,

  4. #4
    Expert éminent Avatar de BufferBob
    Profil pro
    responsable R&D vidage de truites
    Inscrit en
    Novembre 2010
    Messages
    3 038
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : responsable R&D vidage de truites

    Informations forums :
    Inscription : Novembre 2010
    Messages : 3 038
    Points : 8 405
    Points
    8 405
    Par défaut
    salut,

    la commande cut permet de spécifier un délimiteur ainsi que de sélectionner un champs
    sous un autre angle, awk peut aussi s'avérer une alternative intéressante et concise (on peut notamment référencer l'avant dernier champs via $(NF-1) par exemple, lesquels sont délimités par l'option -F)

  5. #5
    Membre à l'essai
    Homme Profil pro
    Technicien réseau
    Inscrit en
    Février 2016
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : Technicien réseau

    Informations forums :
    Inscription : Février 2016
    Messages : 21
    Points : 20
    Points
    20
    Par défaut
    Après vos conseils, je pense avoir trouvé une solution :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    27
    28
    29
    30
    31
    32
     
    cat /home/pi/scripts/fic
    Poli-3;2017-02-09 14:55:00.350;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 1;R;0
    Poli-1;2017-02-09 14:55:00.359;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB2;KODI;Z;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;TITI;data manquante format 1;V;0
    Poli-10;2017-02-09 14:55:01.009;IP_SERVEUR;TESTREJET;TEST_VAL_INT;URB8;KODI;A;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;;;;TITI;data manquante format 1;U;1
    Poli-3;2017-02-09 14:56:00.350;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 1;R;0
    Poli-1;2017-02-09 14:56:00.359;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB2;KODI;Z;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;TITI;data manquante format 1;V;0
    Poli-10;2017-02-09 14:56:01.009;IP_SERVEUR;TESTREJET;TEST_VAL_INT;URB8;KODI;A;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;;;;TITI;data manquante format 1;U;1
    Poli-2;2017-02-09 14:56:01.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;R;10
    Poli-0;2017-02-09 14:56:02.150;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB5;KODI;D;;KO_TEMP;cache;AV5;proz-proe-ticket1;COSA;;;proa-noticket-proa;2016-06-12 14:33:02.389;;;;data OK format 8;;51
    Poli-2;2017-02-09 14:56:02.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;R;10
    Poli-4;2017-02-09 14:56:02.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-3;2017-02-09 14:56:02.650;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-3;2017-02-09 14:56:03.350;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 1;R;0
    Poli-1;2017-02-09 14:56:03.359;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB2;KODI;Z;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;TITI;data manquante format 1;V;0
    Poli-10;2017-02-09 14:56:04.009;IP_SERVEUR;TESTREJET;TEST_VAL_INT;URB8;KODI;A;;OK_URL;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;;;;TITI;data manquante format 1;U;1
    Poli-2;2017-02-09 14:56:04.050;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;R;10
    Poli-0;2017-02-09 14:56:04.150;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB5;KODI;D;;KO_TEMP;cache;AV5;proz-proe-ticket1;COSA;;;proa-noticket-proa;2016-06-12 14:33:02.389;;;;data OK format 8;;51
    Poli-2;2017-02-09 14:56:05.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;;10
    Poli-4;2017-02-09 14:56:05.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-3;2017-02-09 14:56:06.050;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-0;2017-02-09 14:56:06.150;IP_SERVEUR;TESTREJET;TEST_REJET_INT;URB5;KODI;D;;KO_TEMP;cache;AV5;proz-proe-ticket1;COSA;;;proa-noticket-proa;2016-06-12 14:33:02.389;;;;data OK format 8;;51
    Poli-2;2017-02-09 14:56:07.150;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-4;2017-02-09 14:56:08.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-3;2017-02-09 14:56:08.650;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-1;2017-02-09 14:56:08.850;IP_SERVEUR;TESTREJET;TEST_REJET_EXT;URB1;KODI;A;;KO_ERREUR;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;Z;10
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;10
    Poli-9;2017-02-09 14:56:09.650;IP_SERVEUR;TESTREJET;TEST_REJET_ZOP;URB2;KODI;T;;KO_TER;cache;AV5;prob-proa-ticket1;Brique;;;;;;;data manquante format 8;E;10
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;d
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;10
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;
    Poli-5;2017-02-09 14:56:09.350;IP_SERVEUR;TESTREJET;;KODI;I;;KO_BIS;cache;AV1;prob-proa-ticket1;Brique;;;prob-ticket1-proa;2016-06-12 14:33:02.389;;;;data manquante format 8;r;A
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    awk -F ";" '$(NF-1) ~ /[rR]/ {print $0}' /home/pi/scripts/fic | wc -l
    11

    Pour finaliser ma commande, peut-on passer en argument au awk le numéro de ligne à partir duquel on souhaite commencer à lire le fichier ?

    Par avance merci pour vos retour

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2010
    Messages
    345
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2010
    Messages : 345
    Points : 539
    Points
    539
    Par défaut
    Bonjour,
    Le sujet m'avais un peu intéressé pour essayer de comprendre le fonctionnement de awk, alors j'ai fait ça.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    27
    28
    29
    30
    #!/bin/sh
     
    # controle du nombre d'arguments
    if [ "$#" -ne 2 ] ; then
    	echo nombre d\'arguments = "$#"
    	echo utilisation "$0" \"Nombre de lignes\" \"fichier a controler\"
    	exit 1
    fi
     
    NbLigne=$(grep -c '' "$2")
     
    LaLigne=$((NbLigne-$1))
     
    NbRr=$(awk -F \; -v depart=$LaLigne '
    	$(NF-1) ~ /[Rr]/ { matchtot = matchtot + 1
    	if ( NR > depart) matchpar = matchpar + 1 } 
    	END { print matchpar,matchtot }' $2)
     
    #avec bash ou ksh
    #read matchpar matchtot <<< $NbRr
    matchpar=${NbRr% *}
    matchtot=${NbRr#* }
     
    echo "Nous comptabilisons en tout sur les \
    $NbLigne lignes du fichier $2 $matchtot fois \
    le pattern "r" ou "R" sur l'avant dernier champs."
     
    echo "Nous souhaitons comptabiliser 5 fois le \
    pattern "r" ou "R" en recherchant sur les $1 dernières \
    lignes du fichier $2 et nous le trouvons $matchpar fois."
    Je pense que ça doit le faire.

    Cordialement.

  7. #7
    Expert éminent Avatar de BufferBob
    Profil pro
    responsable R&D vidage de truites
    Inscrit en
    Novembre 2010
    Messages
    3 038
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : responsable R&D vidage de truites

    Informations forums :
    Inscription : Novembre 2010
    Messages : 3 038
    Points : 8 405
    Points
    8 405
    Par défaut
    salut,

    Citation Envoyé par fabio1978 Voir le message
    peut-on passer en argument au awk le numéro de ligne à partir duquel on souhaite commencer à lire le fichier ?
    oui, le switch -v permet de passer une variable à awk, la variable interne NR tient à jour le numéro de la ligne courante et on peut y compris se débarasser du | wc -l en faisant un truc du genre :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $ num=10
    $ awk -F';' -vNUMLINE=$num 'NR >= NUMLINE && $(NF-1) ~ /^[rR]$/ {n++} END {print n}' fichier

  8. #8
    Expert confirmé
    Homme Profil pro
    Développeur informatique en retraite
    Inscrit en
    Avril 2008
    Messages
    2 102
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côtes d'Armor (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique en retraite

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 102
    Points : 5 849
    Points
    5 849
    Par défaut
    Citation Envoyé par fabio1978 Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    awk -F ";" '$(NF-1) ~ /[rR]/ {print $0}' /home/pi/scripts/fic | wc -l
    11
    Pour finaliser ma commande, peut-on passer en argument au awk le numéro de ligne à partir duquel on souhaite commencer à lire le fichier ?
    Comme répondu par d'autres, oui, on peut passer à "awk" le numéro de ligne à partir duquel on souhaite commencer à lire le fichier...
    mais on peut aussi utiliser la méthode "standard" unix, le pipe (au prix d'un processus supplémentaire).

    Par exemple, pour commencer à partir de la 30ème ligne comprise (la 1ère étant... la n°1):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    line=30
    tail -n+${line} /home/pi/scripts/fic | awk -F ";" '$(NF-1) ~ /[rR]/ {print $0}' | wc -l

  9. #9
    Membre à l'essai
    Homme Profil pro
    Technicien réseau
    Inscrit en
    Février 2016
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : Technicien réseau

    Informations forums :
    Inscription : Février 2016
    Messages : 21
    Points : 20
    Points
    20
    Par défaut
    Bonjour à tous et merci pour vos différents retour.

    Après quelques jours de repos, je me suis inspiré des différentes propositions au fil des discussions et voici la commande que je souhaitais retenir :

    test avec un fichier contenant 2 erreurs à relever :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    cat /tmp/toto
    Ariane_3;2017-02-20 16:14:28.057;DevCenEsb;PrcCourrier46ae7b7c-eff0-4917-828b-20b1b26d0dd9;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;ENTREE;editionCourrierCentral;evtRiche;46ae7b7c-eff0-4917-828b-20b1b26d0dd9;OSIRIS;MCI0;;;refPRC_524000497__46ae7b7c-eff0-4917-828b-20b1b26d0dd9;2017-02-20 12:00:00.0;COUR;PRC;524000497;Prise en charge du courrier depuis PRC.;;; 
    Ariane_3;2017-02-20 15:34:05.169;DevCenEsb;PrcCourrier1fa10301-7fff-43a7-9131-98e10e636abb;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;SORTIE;editionCourrierCentral;evtRiche;1fa10301-7fff-43a7-9131-98e10e636abb;OSIRIS;MCI0;;;refPRC_524000496__1fa10301-7fff-43a7-9131-98e10e636abb;2017-02-20 12:00:00.0;COUR;PRC;524000496;Fin du traitement de préintégration du courrier.;;R; 
    Ariane_3;2017-02-20 15:34:04.945;DevCenEsb;PrcCourrier1fa10301-7fff-43a7-9131-98e10e636abb;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;ENTREE;editionCourrierCentral;evtRiche;1fa10301-7fff-43a7-9131-98e10e636abb;OSIRIS;MCI0;;;refPRC_524000496__1fa10301-7fff-43a7-9131-98e10e636abb;2017-02-20 12:00:00.0;COUR;PRC;524000496;Prise en charge du courrier depuis PRC.;;r; 
    Ariane_3;2017-02-20 16:14:28.057;DevCenEsb;PrcCourrier46ae7b7c-eff0-4917-828b-20b1b26d0dd9;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;ENTREE;editionCourrierCentral;evtRiche;46ae7b7c-eff0-4917-828b-20b1b26d0dd9;OSIRIS;MCI0;;;refPRC_524000497__46ae7b7c-eff0-4917-828b-20b1b26d0dd9;2017-02-20 12:00:00.0;COUR;PRC;524000497;Prise en charge du courrier depuis PRC.;;; 
     
    ligneascan=1
    chaine1=r
    file=/tmpt/toto
     
    nbchainactu=`awk -F ";"  -v NUMLINE=$ligneascan -v pattern=$chaine1 'BEGIN{IGNORECASE=1} NR >= NUMLINE && $(NF-1) ~ /[pattern]/ {n++} END {print n}' $file`
     
     
    echo "nbchainactu = $nbchainactu"
    nbchainactu = 2
    La valeur retournée est bien celle attendue donc tout va bien


    En revanche, lorsque le fichier ne contient pas le pattern, la valeur retournée est vide alors que je souhaiterai qu'elle soit égale à 0 (zéro)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    cat /tmp/toto
    Ariane_3;2017-02-20 16:14:28.057;DevCenEsb;PrcCourrier46ae7b7c-eff0-4917-828b-20b1b26d0dd9;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;ENTREE;editionCourrierCentral;evtRiche;46ae7b7c-eff0-4917-828b-20b1b26d0dd9;OSIRIS;MCI0;;;refPRC_524000497__46ae7b7c-eff0-4917-828b-20b1b26d0dd9;2017-02-20 12:00:00.0;COUR;PRC;524000497;Prise en charge du courrier depuis PRC.;;; 
    Ariane_3;2017-02-20 15:34:05.169;DevCenEsb;PrcCourrier1fa10301-7fff-43a7-9131-98e10e636abb;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;SORTIE;editionCourrierCentral;evtRiche;1fa10301-7fff-43a7-9131-98e10e636abb;OSIRIS;MCI0;;;refPRC_524000496__1fa10301-7fff-43a7-9131-98e10e636abb;2017-02-20 12:00:00.0;COUR;PRC;524000496;Fin du traitement de préintégration du courrier.;;; 
    Ariane_3;2017-02-20 15:34:04.945;DevCenEsb;PrcCourrier1fa10301-7fff-43a7-9131-98e10e636abb;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;ENTREE;editionCourrierCentral;evtRiche;1fa10301-7fff-43a7-9131-98e10e636abb;OSIRIS;MCI0;;;refPRC_524000496__1fa10301-7fff-43a7-9131-98e10e636abb;2017-02-20 12:00:00.0;COUR;PRC;524000496;Prise en charge du courrier depuis PRC.;;; 
    Ariane_3;2017-02-20 16:14:28.057;DevCenEsb;PrcCourrier46ae7b7c-eff0-4917-828b-20b1b26d0dd9;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;ENTREE;editionCourrierCentral;evtRiche;46ae7b7c-eff0-4917-828b-20b1b26d0dd9;OSIRIS;MCI0;;;refPRC_524000497__46ae7b7c-eff0-4917-828b-20b1b26d0dd9;2017-02-20 12:00:00.0;COUR;PRC;524000497;Prise en charge du courrier depuis PRC.;;; 
     
    ligneascan=1
    chaine1=r
    file=/tmpt/toto
     
    nbchainactu=`awk -F ";"  -v NUMLINE=$ligneascan -v pattern=$chaine1 'BEGIN{IGNORECASE=1} NR >= NUMLINE && $(NF-1) ~ /[pattern]/ {n++} END {print n}' $file`
     
     
    echo "nbchainactu = $nbchainactu"
    nbchainactu =
    Existe t'il une méthode pour "forcer" le awk à me retourner une valeur même nul ou dois-je passer par un "wc -l" pour être sur d'avoir une valeur en retour ?


    Vous remerciant d'avance pour vos retours

    Cordialement,

  10. #10
    Expert éminent Avatar de BufferBob
    Profil pro
    responsable R&D vidage de truites
    Inscrit en
    Novembre 2010
    Messages
    3 038
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : responsable R&D vidage de truites

    Informations forums :
    Inscription : Novembre 2010
    Messages : 3 038
    Points : 8 405
    Points
    8 405
    Par défaut
    salut,

    Citation Envoyé par fabio1978 Voir le message
    Existe t'il une méthode pour "forcer" le awk à me retourner une valeur même nul
    dans ta clause BEGIN tu peux simplement initialiser n=0

  11. #11
    Membre à l'essai
    Homme Profil pro
    Technicien réseau
    Inscrit en
    Février 2016
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : Technicien réseau

    Informations forums :
    Inscription : Février 2016
    Messages : 21
    Points : 20
    Points
    20
    Par défaut
    Alors là bravo, c'est exactement ce que je cherchais.

    la commande finale est donc la suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    ligneascan=1
    chaine1=r
    file=/tmpt/toto
     
    nbchainactu=`awk -F ";"  -v NUMLINE=$ligneascan -v pattern=$chaine1 'BEGIN{IGNORECASE=1 ; n=0} NR >= NUMLINE && $(NF-1) ~ /[pattern]/ {n++} END {print n}' $file`
    Merci a tous pour votre aide

    Cordialement,

  12. #12
    Membre à l'essai
    Homme Profil pro
    Technicien réseau
    Inscrit en
    Février 2016
    Messages
    21
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loiret (Centre)

    Informations professionnelles :
    Activité : Technicien réseau

    Informations forums :
    Inscription : Février 2016
    Messages : 21
    Points : 20
    Points
    20
    Par défaut
    Bonjour,

    Je reviens à nouveau sur le sujet car une nouvelle directive vient de m'être demandé et je pêche un peu pour trouver une solution.

    Pour reprendre l'origine de la discussion, l'objectif était d'analyser les x dernières lignes d'un fichiers afin d'identifier et de comptabiliser si l'avant dernier champ était un "R" ou "r".

    Le code fonctionnant parfaitement grâce à votre aide est le suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    ligneascan=1
    chaine1=r
    file=/tmpt/toto
     
    nbchainactu=`awk -F ";"  -v NUMLINE=$ligneascan -v pattern=$chaine1 'BEGIN{IGNORECASE=1 ; n=0} NR >= NUMLINE && $(NF-1) ~ /[pattern]/ {n++} END {print n}' $file`
    Une nouvelle contrainte vient de m'être demandé et je dois en plus vérifier si le 7 ème champ de la ligne contient le pattern suivant "AARC_TACHE_UR_CONSO"
    J'aurai souhaité, dans la mesure du possible, faire évoluer la commande sans devoir tout modifier.

    Voici une extraction du fichier (=> on devrait retourner une seule occurence trouvée avec les 2 critères de recherche) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    cat /tmp/toto
    cat /tmp/toto
    Ariane_3;2017-02-20 16:14:28.057;DevCenEsb;PrcCourrier46ae7b7c-eff0-4917-828b-20b1b26d0dd9;EDITION_COURRIER_PRC;HERMES;AARC_TACHE_UR_CONSO;D;*;ENTREE;editionCourrierCentral;evtRiche;46ae7b7c-eff0-4917-828b-20b1b26d0dd9;OSIRIS;MCI0;;;refPRC_524000497__46ae7b7c-eff0-4917-828b-20b1b26d0dd9;2017-02-20 12:00:00.0;COUR;PRC;524000497;Prise en charge du courrier depuis PRC.;;; 
    Ariane_3;2017-02-20 15:34:05.169;DevCenEsb;PrcCourrier1fa10301-7fff-43a7-9131-98e10e636abb;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;SORTIE;editionCourrierCentral;evtRiche;1fa10301-7fff-43a7-9131-98e10e636abb;OSIRIS;MCI0;;;refPRC_524000496__1fa10301-7fff-43a7-9131-98e10e636abb;2017-02-20 12:00:00.0;COUR;PRC;524000496;Fin du traitement de préintégration du courrier.;;R; 
    Ariane_3;2017-02-20 15:34:04.945;DevCenEsb;PrcCourrier1fa10301-7fff-43a7-9131-98e10e636abb;EDITION_COURRIER_PRC;HERMES;AARC_TACHE_UR_CONSO;D;*;ENTREE;editionCourrierCentral;evtRiche;1fa10301-7fff-43a7-9131-98e10e636abb;OSIRIS;MCI0;;;refPRC_524000496__1fa10301-7fff-43a7-9131-98e10e636abb;2017-02-20 12:00:00.0;COUR;PRC;524000496;Prise en charge du courrier depuis PRC.;;r;
    Ariane_3;2017-02-20 16:14:28.057;DevCenEsb;PrcCourrier46ae7b7c-eff0-4917-828b-20b1b26d0dd9;EDITION_COURRIER_PRC;HERMES;AARC_COUR_PRC;D;*;ENTREE;editionCourrierCentral;evtRiche;46ae7b7c-eff0-4917-828b-20b1b26d0dd9;OSIRIS;MCI0;;;refPRC_524000497__46ae7b7c-eff0-4917-828b-20b1b26d0dd9;2017-02-20 12:00:00.0;COUR;PRC;524000497;Prise en charge du courrier depuis PRC.;;;

    Auriez-vous SVP une piste ou solution d'évolution pour répondre à ce besoin ?
    Par avance merci

    Cordialement,

  13. #13
    Expert confirmé
    Homme Profil pro
    Développeur informatique en retraite
    Inscrit en
    Avril 2008
    Messages
    2 102
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côtes d'Armor (Bretagne)

    Informations professionnelles :
    Activité : Développeur informatique en retraite

    Informations forums :
    Inscription : Avril 2008
    Messages : 2 102
    Points : 5 849
    Points
    5 849
    Par défaut
    À tester:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    nbchainactu=`awk -F ";"  -v NUMLINE=$ligneascan -v pattern=$chaine1 'BEGIN{IGNORECASE=1 ; n=0} NR >= NUMLINE && $7 ~ /AARC_TACHE_UR_CONSO/ && $(NF-1) ~ /[pattern]/ {n++} END {print n}' $file`

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 1
    Dernier message: 29/04/2015, 15h18
  2. log4j: Répétitions des lignes dans le fichier log
    Par troumar dans le forum EDI et Outils pour Java
    Réponses: 0
    Dernier message: 06/05/2011, 11h02
  3. Comment lire la dernière ligne d'un fichier text.
    Par Ardely dans le forum Delphi
    Réponses: 29
    Dernier message: 20/01/2007, 23h29
  4. Ajouter des lignes dans un fichier *.log
    Par Fred2209 dans le forum C++Builder
    Réponses: 4
    Dernier message: 15/12/2006, 15h15
  5. [C] lecture des n lignes d'un fichier
    Par felicity dans le forum C
    Réponses: 12
    Dernier message: 12/01/2006, 23h12

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo