Combinations

Hello All,
i have two files, one of the format

A 123
B 124
C 234
D 345

And the other

A 678
B 789
C 689
D 567

I would like to combine them into one file with three columns:

A 123 678
B 124 789
C 234 689
D 345 567

Is it possible to do this in unix? I know it can easily be done with sql.

Any assistance will be appreciated.
Khoom

try this,

#! /usr/bin/ksh

temp=1
cut -d" " -f2 file2 | while read line
do
var[$temp]=$line
temp=$(($temp + 1))
done

temp=1
while read line
do
echo $line ${var[$temp]}
temp=$(($temp + 1))
done < file1

exit 0

join does this for you.

try man join.

a simple join ???

join file1 file2

yes this would have done the work,

but only if the input files are sorted in increasing collating sequence

what if the input file file1 is (not sorted)

A 123
C 524
B 234
D 345
join file1 file2 

would fail

thats why i gave the above soln !!!

how about "paste"