I want to use the numbers of file whitelist.txt to get a unique identification number from file list.txt based on the order specified by file whitelist.txt.Example:$ cat whitelist.txt:  2  5  7  10   11(+8,000 more lines)$ cat list.txt  2  172363  14  17  612851  172414  172418  172419  172424  19  72457  (+ 150,000 more lines)Such that I can re-direct to a new file:$ cat newfile.txt  172363  612851  172418  19   72457  (+8,000 more lines)NOTE: This question has been modified. The answers below prior to May 5th, 2017 were based on input samples (list.txt) that were formatted as (e.g. first row) >CLocus_2_Sample_ (instead of only the number 2) and the file name was file.fa (not file.txt).  
Using numbers in file A to get unique ID from file B based on the order specified by file A
text processing;awk;sed;grep;uniq
Based on the revised data, try something like this:$ sed -nf <(sed 's/.*/&p/g' whitelist.txt) list.txt >newfile.txtThis transforms the entries of whitelist.txt file from i.e 2 to 2p which instructs outer sed to print that line 2 ==> equals to sed -n '2p' ==> prints the second line.The same happens for all entries of whitelist.txt, creating a sed script (feeding outer sed with process substitution), containing 2p,5p,7p,etc and those lines of list.txt are printed. Alternative: Pre-process the whitelist.txt:sed 's/.*/&p/g' whitelist.txt >whitelist2.txt  #or sed -i '....' whitelist.txt to overwrite whitelist.txtsed -nf whitelist2.txt list.txt # you can redirect output to >newfile.txt