|
Select lines from FileA based on a key field in FileB
I want to select lines from FileA based on a key field in FileB.
egrep does this nicely:
"egrep -w '0132874|0132880|0100765' < " FileA
Suppose FileB consists of three lines:
0132874
0132880
0100765
Is there a way to code egrep to do the selection?
I really like code which does not use explicit loops so my interest is to find a grep or egrep or sed (or some other) command to perform this function.
Neither file is sorted on the key field but they could be. There is no requirement to keep the files in their present order.
We may assume that each key value in each file is unique.
Thanks!
Daniel B. Martin
|