I have a file with 1 million lines. I want to extract lines from line 10001 to 500000 How to do this?
sed is your friend:
sed -n '10001,500000p;500001q'
Note that 500001q is needed to stop further file processing. Otherwise it will still read the file till the very end. Thanks for hint on this to @Freddy.
Might as well have a
tail solution as well:
head -n 500000 yourfile.txt | tail -n +10001
tail -n +10 is different from
tail -n 10 – the former starts at line 10, the latter only prints the last 10 lines.)