Match pattern and get lines numbers in a vector

view story

http://www.unix.com – Hi everyone, I am new to shell scripting, and would appreciate your help on following problem. I need to search a file for a pattern, then get the number of each line that matches the given pattern. Then I need to search those specific line numbers from the first file in a second file and print the entire lines. I tried with grep -n 'pattern' from the first file, which gives me: 21: pattern 37: pattern 58: pattern ... now I need to get 21,37,58... in a vector or something, and display these lines from the second file. I hope I made myself clear. thanks in advance (HowTos)