Concatener deux fichiers

Fermé
sophiasophia Messages postés 1 Date d'inscription mardi 20 mai 2014 Statut Membre Dernière intervention 20 mai 2014 - 20 mai 2014 à 00:57
dubcek Messages postés 18718 Date d'inscription lundi 15 janvier 2007 Statut Contributeur Dernière intervention 22 mars 2024 - 20 mai 2014 à 09:06


j'ai une question concernant la concatenation de deux fichiers en shell : j'ai deux fichiers txt
fichier1.txt contient ceci :
chemin=~/projectest/images/image 1.jpg
chemin=~/projectest/images/image 2.jpg
chemin=~/projectest/images/image 3.jpg
fichier2.txt contient ceci:
1:image1.jpg:
2:image2.jpg:
3:image3.jpg:
Ma question est comment je peux concatener ces deux fichiers de facon de chaque image a le chemin d'acces correspondant je cherche ce resulat par exemple
1:image1.jpg:~/projectest/images/image 1.jpg

merci d'avance
A voir également:

1 réponse

dubcek Messages postés 18718 Date d'inscription lundi 15 janvier 2007 Statut Contributeur Dernière intervention 22 mars 2024 5 615
20 mai 2014 à 09:06
hello
$ awk -F / 'FNR==NR {n=$NF; gsub(" ", "", n); sub("^[^=]*=", ""); t[n]=$0; next} {split($0, a, ":"); print $0 t[a[2]]}' fichier1 fichier2
1:image1.jpg:~/projectest/images/image 1.jpg
2:image2.jpg:~/projectest/images/image 2.jpg
3:image3.jpg:~/projectest/images/image 3.jpg
0