If you want a shell script you can use that
Code:
#! /bin/bash
espacios=IFS
IFS="
"
for i in `cat $1`
do
name=`echo $i | cut -d" " -f1`
echo $i > aux
cat $2 | grep "^$name " | cut -d" " -f2 >> aux
cat aux | tr -s "\n" " " >> aux2
echo >> aux2
done
IFS=$espacios
unset espacios
rm aux