This question already has an answer here:
- cat line X to line Y on a huge file 6 answers
What is the simplest way to extract from a file a line given by its number. E.g., I want the 666th line of
somefile. How would you do this in your terminal, or in a shell script?
I can see solutions like
head -n 666 somefile | tail -n 1, or even the half-incorrect
cat -n somefile | grep -F 666, but there must be something nicer, faster, and more robust. Maybe using a more obscure unix command/utility?