Hi,
I have two files consisting of two columns. So I want to merge column 2 if column 1 is the same. So heres an example of what I mean.
FILE1
driver 444
car 333
hat 222
FILE2
driver 333
car 666
hat 999
So I want to merge the column 2's together so there is no gap... so the output file will look like this...
driver 444333
car 333666
hat 222999
Currently I am using this script but I can only get it to work for column 2 if column 1 is removed.
awk 'NR==FNR { a[c=FNR]=$0; next } { printf "%-8s%s\n", a[FNR], $0 } END { for(i=FNR+1;i<=c;i++) print a [i]}' FILE2.txt FILE2.txt > output.txt
Please give clear requirement.
sorry for my errors.... I mean columns...
If you dont mind my giving you a simple piece of code...
while read name value_in_file1
do
value_in_file2=`grep $name file2.txt |awk '{print $2}'`
echo $name $value_in_file1$value_in_file2
done < file1.txt
panyam
5
awk '{a[$1]=a[$1]$2} END {for(i in a) print i , a}' file1 file2