Awk to print values of second file

Hello,

I have a data file with 300,000 records in it, and another file which contains only the line numbers of roughly 13,000 records in the data file which have data integrity issues. I'm trying to find a way to print the original data by line number identified in the second file. How can I do this?

Please advise.

Thanks!
Pete

awk 'FNR==NR { LINE[$1]++; next }; LINE[FNR]' linesfile datafile
awk '# FNR is the line number for a particular file, NR is the total lines processed.
# They will only be equal when the very first file is being processed.
# So for the first file, load each line into an array for later reference,
# then start over on the next line without executing any statements below it.
FNR==NR { LINE[$1]++; next };
# Print all lines where the line number in the file matches a line number from linesfile.
LINE[FNR]' linesfile datafile

I'd been :wall: on this for hours. Thanks for your help!:smiley: