printing with awk through while loop

ive input file contains to clums a and b spreated by pipe
a | b
123|456
323|455

and
xyz contains other info about a and b

now i want to print as follows:

a | b | "info from xyz"

but "info from xyz" might be more than 1 line and i want to keep the format to 3 cloums.
how to do it?
i tried the belw script but printing was worng.

Quote:
while IFS='|' && read a b
do
c=`egrep ''$a'|'$b'' xyz.txt`
awk '{print $a":" $b":" $C}' > output.txt
echo "-----------" > output.txt
done < input.txt

How do you propose to keep the input in three columns? Change the line endings inside $c to some other character, or repeat the fields from a and b for each line in $c?

Your awk script doesn't know about the shell's $c variable, they are not automatically communicated between the shell and awk so you need to do that somehow. However, the obvious solution fails to fix the problem with the multi-line output from $c.

awk -F '|' 'NR==FNR { c[a b] = 1; next; }
    { if c[$1 $2] { print } }' input.txt xyz.txt

use sed to delete the new line chars from the c$ variable maybe? (i dont think i got your problem completly)

Whatever which way you take, you should preformat your 2nd file with sed or awk so that everything that should be in a single row, is a single row. Then just use what era posted. If it is a simple pasting of files together, you can also use paste, but since you used egrep in your example, I guess "join" might be an option too.