On Sat, Mar 30, 2013 at 10:27:05PM -0400, Calvin Morrison wrote: > Is there a better way to read a whole line?
For this tool you don't need to read whole lines, just read blocks and count newlines until you perhaps get to the right line number, and print everything the next newline. I agree that sed and awk are somewhat monsterous. I suggest to extend your program so it can also print a range of lines (and thus subsume the functions of 'head' and 'tail' while doing more and yet staying fairly focused). You could perhaps use negative numbers to count back from the final line. It should be able to cut off 6 lines from the end of a file, or print from lines 10 through to the 2nd-last line. Ideally lines should be numbered from zero, and ranges exclude the upper limit, but that might make things weird for humans!