I am able to join (--right) the 2 files based on the key "phone" using "csvjoin", and then copy/pasting appropriate column and deleting the unnecessary one.
You say that the input files are CSVs, but that usually means that a single character is used to separate fields in those files. Instead of that, the files you have shown us have varying numbers of spaces between fields (and in the case of one line in a.csv ), some extraneous spaces at the end of the line).
I will make the wild guess that your real input files are intended to be <tab> separated instead of separated by sequences of one or more <space>s. I further assume that you want the output to be in the same order as the sequence of lines that appear in the a.csv input file. If all of these assumptions are correct, the following seems to produce the output you want (except for the line with the trailing <tab> or <space>s in a.csv :
awk '
FNR == NR {
car[$1] = $2
next
}
$2 in car {
$0 = $0 "\t" car[$2]
}
1' b.csv a.csv
which produces the output:
name phone adress car
xy 1234 asbd honda
yz 2134 asbdf toyota
tc 6789 salkdur bmw
As always, if you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk .
If you choose not to show us sample data that reflects the contents of your actual files, the likelihood of getting a suggestion that will work for you diminishes greatly. If what you are given as suggestions don't work for you, we will have to assume that you will be able to modify our suggestions to work with your real data.
We certainly know that you won't complain that our suggestions don't work with your real data if you are unwilling to tell us what your real data looks like.