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.
Can this be accomplished, fast?
Notes:
- I managed to get the first n lines, fast.
- It is ok if I get the last n bytes. (I used this https://mcmap.net/q/393436/-get-the-first-n-characters-of-a-large-file-with-powershell for the first n bytes).
Solutions here Unix tail equivalent command in Windows Powershell did not work.
Using -wait
does not make it fast. I do not have -tail
(and I do not know if it will work fast).
PS: There are quite a few related questions for head
and tail
, but not focused on the issue of speed. Therefore, useful or accepted answers there may not be useful here. E.g.,
Windows equivalent of the 'tail' command
CMD.EXE batch script to display last 10 lines from a txt file
Extract N lines from file using single windows command
powershell to get the first x MB of a file
https://superuser.com/questions/859870/windows-equivalent-of-the-head-c-command