How to extract lines from a large file in the terminal

Here’s a quick tip on slicing a few lines out of a file that is too large to open in a text editor.

This extracts lines 10,350 to 10,400 and saves them in a file named sliced.txt:

$ sed -n 10350,10400 dump.sql > sliced.txt

Or just pipe it into #vim (or another editor) if it isn’t too large:

$ sed -n 10350,10400 dump.sql | vim -

(sed is a stream editor.)

1 Like