Say I have a huge text file (>2GB) and I just want to cat the lines X to Y (e.g. 57890000 to 57890010).
From what I understand I can get a somewhat similar behaviordo this by piping head into tail or viceversa, i.e.
head -A /path/to/file | tail -B or alternatively
tail -C /path/to/file | head -D where A,B,C and D can be computed from the number of lines in the file, X and Y.
But there are two problems with this approach:
- You have to compute
A,B,CandD. - The commands could
pipeto each other many more lines than I am interested in reading (e.g. if I am reading just a few lines in the middle of a huge file)
Is there a way to have the shell just work with and output the lines I want? (while providing only X and Y)?