I want to take a list of numbers representing line numbers of a source file I want to filter and filter those lines from the source file. How I can build a unix pipeline to extract these lines from the source file?The pipeline might look like:cat sourcefile.tsv | some-filter linenumbers.txt  > extractedrecords.tsvI can't think of a combination of unix tools to do this off the top of my head. The fallback is to write a bash script that does sed -n [number]p sourcefile.tsv for every number in linenumbers.txt.If my fallback plan is reasonably efficient compared to alternatives, please let me know that too.
How do I efficiently select specific line numbers from a list of records?
text processing;sed;filter
Assuming linenumbers.txt has one number per lineawk 'NR == FNR{a[$0]; next};FNR in a' linenumbers.txt sourcefile.csv > extractedrecords.tsvMight do the job.Or, with bashjoin  -t':' -o2.1,2.2  <(sort linenumbers.txt) <(awk '{print NR:$0}' \sourcefile.csv | sort -k1,1 -t':')  | sort -k1,1n -t':' | cut -f2- -d':'All the extra jumping through hoops is needed because join does not support numerically sorted input files