2

I have a very large text file and I want to view, say, lines 2000 through 2010 (with the line numbers included)

I know one sort of roundabout way of getting there:

sc -l [file]
cat -n [file] | tail -n [previous result - 2000] | head -n 10

But it feels like there must be a better way. Is there?

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
Dan Tao
  • 1,109

1 Answers1

5

You could use sed if you know the lines you want.

sed -n X,Yp file.txt

Or if it's stuff between some REGEX, with awk:

awk '/FIRST REGEX/,/LAST REGEX/' input.txt

Or an awk way of doing the sed suggestion:

awk 'NR>=X && NR<=Y' file.txt

nerdwaller
  • 18,014