cat input.txt |
while IFS='|' read a b; do
adata=`grep $a data.txt |head -1`
bdata=`grep $b data.txt |head -1`
echo $a '|' $b '|' $adata '|' $bdata
done
The problems here are that (1) subsequent matches in data.txt are not matched, and (2) unmatched entries are not reported. To fix these, you need a more elaborate script with awk or perl. It CAN be done in shell script. Let's see where this gets you first.
it worked fine. I did it without ' head -1' since i need all the matches for both $a and $b
BUT..
if $a has more than 1 match in data.txt, it wont be printed in tablular form.
I need to export the results to Excel so the can more proccessed further.
lets say from data.txt we have more than 1 line matching $a, and output will be:
What i need now ,at least, is to have the output as follows:
|
so i can use text wizard in Excel to import it and keep it inshape.
Hope u got my point