I want to extract just the lines with specific line numbers from a file (I have about 20-50 line numbers, the file has 30,000 lines). So far, the most concise way I’ve found to do this is e.g.:
gawk 'BEGIN {split("13193,15791,16891", A, ",")} NR in A' <file_name>
but it seems like I should be able to further reduce the amount of typing involved. I’ve looked at sed but I think I need an -n and a -p for each line number, also thought about cat -n with grep but it’s more verbose than the above. Does anyone know a better way?
Sed can be more concise: