extract the lines by index number

Hi All,

I want to extract the lines from file1 by using the index numbers from file2. In example,

 
cat file1.txt 
 
265 ABC 956  ...
698 DFA 456  ...
456 DDD 145 ...
125 DSG 154 ...
459 CGB 156 ...
490 ASF 456 ...
484 XFH 489 ...
679 hgt 481 ...
111 dfg 986 ...
356 vhn 444 ...
878 fth 256 ...
356 fgf 468 ...
489 fsr 480 ...
369 dgd 456 ...
...
 
 
cat file2.txt
 
3, 9, 12, ...

So, the output.txt file will be

 
cat output.txt
 
456 DDD 145 ...
111 dfg 986 ...
356 fgf 468 ...
...

Thanks in advance,

What have you tried so far and where exactly are you stuck?

Does file2.txt have just one line having value separated by comma? or are they in multiple line?

--ahamed

file2.txt is just only 1 line.

Once again - please show the effort. Show exactly where you're stuck!
How is this current thread different from your old thread?

Isn't this also the "negation" of this thread (or TGIF and time for me to stop looking...)?

In which case it is not a big effort to figure out what is to be modified...

Hi vgersh99,

Thanks for reminding my old thread. Actually, i do not know how i can see only the threads posted by me. So, i lost it. Now, i see the solution.

I appreciate your reminding.

Click on your own username beside your post there, 'statistics', and find all your own posts.