Hi everyone! Long time reader, first time poster.
I have two files, FILE 1 contains two columns. Column 2 are #'s that are NR's for FILE 2.
I.e.
FILE 1;
183088561 4
37922422 10
And FILE 2 is just a bunch of data, i.e.
FILE 2;
75076818 6577.50 353 20 51 16
75086808 6558.50 353 20 51 26
75096799 6550.06 353 20 51 36
75106799 6549.20 353 20 51 46
75116789 6553.60 353 20 51 56
75126780 6561.52 353 20 52 06
75136780 6571.62 353 20 52 16
75146770 6582.85 353 20 52 26
75156761 6594.52 353 20 52 36
75166751 6606.00 353 20 52 46
75176751 6616.95 353 20 52 56
I want to print the lines in FILE 2 associated with the NR from column 2 in FILE 1.
I.e. the script should print;
75106799 6549.20 353 20 51 46
75166751 6606.00 353 20 52 46
These are simple files, the real one would be a few dozen lines for FILE 1 and 10k+ lines for FILE 2.
I was trying to do with with a 1-line awk statement..(since its part of a much larger script...)
awk 'NR==FNR {a[$1]=$2; next}; END NR==a{$1] {print $0}' file1 file2 > tmp
which doesnt work...
any suggestion?
-Thanks!
ashton