Efficient implementation of tail -n
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/10164597/how-would-you-implement-tail-efficiently">How would you implement tail efficiently?</a>  </p>
</blockquote>



<p>A friend of mine was asked how he'd implement <code>tail -n</code>. 
To be clear, we are required to print the last <code>n</code> lines of the file specified.</p>

<p>I thought of using an array of n strings and overwriting them in a cyclic manner.
But if we are given, say a <code>10 GB</code> file, this approach doesn't scale at all.</p>

<p>Is there a better way to do this?</p>
