How to quickly print certain lines of a huge file by number

If you have to work with huge text files, you know that most editors as well as less are very slow at jumping to a certain line in the latter part of a large file. Turns out that GNU sed is very good at it, although it will of course not replace an editor. For most people at least, those who write Tetris in sed will probably be fine.

$ wc -l uniprot_sprot.dat
31510440 uniprot_sprot.dat

$ time sed -n '30000000p' uniprot_sprot.dat
real    0m8.982s

$ time sed -n '29999900,30000000p' uniprot_sprot.dat
real    0m9.242s

Tags: , , ,

%d bloggers like this: