AWK : créer des champs à partir d'un texte en colonne
Résolu/Fermé
misk-5211
-
Modifié le 24 mars 2021 à 16:48
mamiemando Messages postés 33134 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 31 mai 2024 - 25 mars 2021 à 12:45
mamiemando Messages postés 33134 Date d'inscription jeudi 12 mai 2005 Statut Modérateur Dernière intervention 31 mai 2024 - 25 mars 2021 à 12:45
A voir également:
- AWK : créer des champs à partir d'un texte en colonne
- Ps awk ✓ - Forum Debian
- Awk xml ✓ - Forum Shell
- Awk windows - Forum Windows
- Awk separateur ✓ - Forum Shell
- Awk cut ✓ - Forum Shell
2 réponses
mamiemando
Messages postés
33134
Date d'inscription
jeudi 12 mai 2005
Statut
Modérateur
Dernière intervention
31 mai 2024
7 756
24 mars 2021 à 16:55
24 mars 2021 à 16:55
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
Merci infiniment. Bien cordialement.
mamiemando
Messages postés
33134
Date d'inscription
jeudi 12 mai 2005
Statut
Modérateur
Dernière intervention
31 mai 2024
7 756
25 mars 2021 à 12:45
25 mars 2021 à 12:45
De rien ! Bonne continuation !