Grabbing lines from one file based on another file

Hi everyone,

I have a file that contains multiple columns. Basically the identifiers are on column 1. Here is an example:

target1  6.7  8.4
target2  5.3  2.3
target3  4.3  2.3

My goal is to pull out certain identifiers from column 1 (pull the entire row) and put it into another file. The list of identifiers that I want will be in another file that looks like this

target1
target2

So ultimately my output will hopefully look like this:

target1  6.7  8.4
target2  5.3  2.3

These files are very large. I can do selected ones manually by using the unix code grep but this is a little bit more complex.

thanks

try this. you can modify accordingly

while read line
do
     grep $line flat_file.txt >> output.txt
done < list_of_ident.txt

no need of while loop

grep -f file2 file1 >final_file

oops. didn't know that. thanks

ive been using the

grep -f file2 file1 >final_file

but it is VERY slow. How can I make things go faster? the first file is not sorted... could this be a reason?