title: Get last n lines or bytes of a huge file in Windows (like Unix's tail). Avoid time consuming options
body: <p>I need to retrieve the last n lines of huge files (1-4 Gb), in Windows 7.
  Due to corporate restrictions, I cannot run any command that is not built-in.
  The problem is that all solutions I found appear to read the whole file, so they are extremely slow.</p>
  
  <p><strong>Can this be accomplished, fast?</strong></p>
  
  <p>Notes:</p>
  
  <ol>
  <li>I managed to get the first n lines, fast. </li>
  <li>It is ok if I get the last n bytes. (I used this <a href="https://stackoverflow.com/a/18936628/2707864">https://stackoverflow.com/a/18936628/2707864</a> for the first n bytes).</li>
  </ol>
  
  <p>Solutions here <a href="https://stackoverflow.com/questions/4426442/unix-tail-equivalent-command-in-windows-powershell">Unix tail equivalent command in Windows Powershell</a> did not work.
  Using <code>-wait</code> does not make it fast. I do not have <code>-tail</code> (and I do not know if it will work fast).</p>
  
  <p>PS: There are quite a few related questions for <code>head</code> and <code>tail</code>, but not focused on the issue of speed. Therefore, useful or accepted answers there may not be useful here. E.g.,</p>
  
  <p><a href="https://stackoverflow.com/questions/1295068/windows-equivalent-of-the-tail-command">Windows equivalent of the &#39;tail&#39; command</a></p>
  
  <p><a href="https://stackoverflow.com/questions/523181/cmd-exe-batch-script-to-display-last-10-lines-from-a-txt-file">CMD.EXE batch script to display last 10 lines from a txt file</a></p>
  
  <p><a href="https://stackoverflow.com/questions/27932722/extract-n-lines-from-file-using-single-windows-command">Extract N lines from file using single windows command</a></p>
  
  <p><a href="https://serverfault.com/questions/490841/how-to-display-the-first-n-lines-of-a-command-output-in-windows-the-equivalent">https://serverfault.com/questions/490841/how-to-display-the-first-n-lines-of-a-command-output-in-windows-the-equivalent</a></p>
  
  <p><a href="https://stackoverflow.com/questions/888063/powershell-to-get-the-first-x-mb-of-a-file">powershell to get the first x MB of a file</a></p>
  
  <p><a href="https://superuser.com/questions/859870/windows-equivalent-of-the-head-c-command">https://superuser.com/questions/859870/windows-equivalent-of-the-head-c-command</a></p>