vlookup in file with string search

Dear All

I had two input file mention as below. Now i want to get op form mention file as below. Kindly how i get do it. Is there any thing in unix like vlookup?.

FILE 1:
BSC1

RXOTRX-48-8 COM MBL
RXOTRX-48-9 COM MBL

FILE2:
RXOTX-48-8 BHOR04C
RXOTX-48-9 BHOR04C

op:
RXOTRX-48-8 COM MBL BHOR04C
RXOTRX-48-9 COM MBL BHOR04C
r

Regards
jaydeep

Use the "join" command:

$
$ cat file_1
RXOTRX-48-8 COM MBL
RXOTRX-48-9 COM MBL
$
$ cat file_2
RXOTRX-48-8 BHOR04C
RXOTRX-48-9 BHOR04C
$
$ join file_1 file_2
RXOTRX-48-8 COM MBL BHOR04C
RXOTRX-48-9 COM MBL BHOR04C
$
$

HTH,
tyler_durden

You can add a little more flexibility in the join command by formatting the output so you can change the order of the fields. Remember to use join both files must be sorted on the field on which you create the join

sort -k1,1 file1 > file1s
sort -k1,1 file2 > file2s

join -1 1 -t" " -o "1.1,1.2,1.3,2.2" file1s file2s

# -1 1    # compare boths files on field 1 of first file on commandline
# -t " "   # file delimiter is {space} or any other character you choose
# -o       # print field 1 from file1s "1.1", print field 2 from file1s "1.2" etc.