awk 'NR == FNR {nums[$1]; next} FNR in nums' numberfile datafile
simply referring to an array subscript creates the entry. Looping over the first file, while NR
(record number) is equal to FNR
(file record number) using the next
statement stores all the line numbers in the array. After that when FNR
of the second file is present in the array (true) the line is printed (which is the default action for “true”).