AWK : créer des champs à partir d'un texte en colonne
Résolu
A voir également:
- AWK : créer des champs à partir d'un texte en colonne
- SED ou Awk sous windows ?? - Forum Windows
- Suppression de lignes en awk ✓ - Forum Shell
- Awk : tri selon la date ✓ - Forum Shell
- Fonctionnement de foreach et awk et set ✓ - Forum Shell
- Commande bash awk, comment mettre en variables. ✓ - Forum Linux / Unix
2 réponses
Bonjour,
toto.txt
toto.awk
Exécution
Bonne chance
toto.txt
date-1
nature-1
montant-1
date-2
nature-2
montant-2
date-3
nature-3
montant-3
toto.awk
BEGIN { i = 0; s = ""; } { if (s) { s = s " ; " $0; } else { s = $0 } i += 1 if (i % 3 == 0) { print(s); s = ""; } }
Exécution
(mando@silk) (~) $ awk -f toto.awk toto.txt
date-1 ; nature-1 ; montant-1
date-2 ; nature-2 ; montant-2
date-3 ; nature-3 ; montant-3
Bonne chance