Bonjour !

J'ai un dossier titi contenant plusieurs dossiers nommés toto_tata. Chaque dossier contient (entre autres) un fichier backtrace.log

Je souhaite créer un fichier .csv avec une seule ligne par fichier backtrace.log qui devrait ressembler a ça:

toto1;tata1;mot suivant l'occurrence1;mot suivant l'occurrence2;mot suivant l'occurrence3
toto2;tata2;mot suivant l'occurrence1;mot suivant l'occurrence2;mot suivant l'occurrence3
etc...
(autant de lignes que de fichiers backtrace.log - pas de chiffre après toto ou tata en vrai )

Pour le moment ce code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
for fn in /CHEMIN/VERS/titi/*/*.log; do
awk -F'[ \\+]' '{NR==1; OFS=";"
  for (i=1;i<=NF;i++) {
        if ($i=="RIP:"){print FILENAME,$(i+1)>>"/CHEMIN/VERS/titi/export.csv"};
		}}' $fn
done
...me donne ça:
CHEMIN/VERS/titi/toto_tata1;mot suivant l'occurrence1
CHEMIN/VERS/titi/toto_tata1;mot suivant l'occurrence2
CHEMIN/VERS/titi/toto_tata1;mot suivant l'occurrence3
CHEMIN/VERS/titi/toto_tata2;mot suivant l'occurrence1
CHEMIN/VERS/titi/toto_tata2;mot suivant l'occurrence2
CHEMIN/VERS/titi/toto_tata2;mot suivant l'occurrence3
...

(pas de chiffre après toto_tata en vrai )

...et ce code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
for fn in /GNOC/Kernel_panic/Imports/*/*.log; do
printf $fn | awk -F'[_/]' '{print $(NF-2)";"$(NF-1)}'
done
me donne:

toto1;tata1
toto2;tata2
etc...

Sinon avec print ARGV[1] ce code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
for fn in /CHEMIN/VERS/titi/*/*.log; do
awk 'BEGIN{ORS=";"; print ARGV[1]}' $fn
done
...me donne:
/CHEMIN/VERS/titi/toto_tata1;/CHEMIN/VERS/titi/toto_tata2;/CHEMIN/VERS/titi/toto_tata3;etc...

J'ai essayé de mettre un print ARG[1] avant la boucle de la commande awk mais j'arrive pas.

(Vous avez compris, je suis un newbie!)