Problème awk pour récuperer des champs
Bonjour,
je souhaite récuperer le champs $2 sous certaines conditions :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| for nom in $(awk 'BEGIN{FS=";"}{print $1}' < verif2.log )
do
for compte in $(awk 'BEGIN{FS=";"}{print $1}' < verif1.txt )
do
if [ $nom = $compte ]
then
# awk 'BEGIN{FS=";" ; nom_exp=$nom }{$1 == nom_exp} {print $2}' verif1.txt > resultat_final.log
# awk '{if ($1 == $nom) {print $2} fi }' verif1.txt > resultat_final.log
fi
done
done |
Merci pour la réponse
awk et comparaison fichiers
bonjour,
j'ai testé les deux techniques (voir dans le commentaire du code shell #mais ça ne marche pas)
pouvez-vous me dire comment je pourrais comparer la valeur d'une variable avec le premier champs d'un fichier , en cas d'égalité je récupere le deuxieme champs du fichier.?
merci
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
for nom in $(awk 'BEGIN{FS=";"}{print $1}' < verif2.log )
do
for compte in $(awk 'BEGIN{FS=";"}{print $1}' < verif1.txt )
do
if [ $nom = $compte ]
then
##############################################
awk 'BEGIN{FS=";" ; nom_exp=$nom }{$1 == nom_exp} {print $2}' verif1.txt > resultat_final.log
awk '{if ($1 == $nom) {print $2} fi }' verif1.txt > resultat_final.log
###################################################
fi
done
done |