Skip to content

Instantly share code, notes, and snippets.

@SmugZombie
Created July 8, 2016 06:26
Show Gist options
  • Save SmugZombie/0720931b2439fdb2d01d5870d1c7e67f to your computer and use it in GitHub Desktop.
Save SmugZombie/0720931b2439fdb2d01d5870d1c7e67f to your computer and use it in GitHub Desktop.
tail.ahk
; Allows you to tail a file providing the path
Tail(k,file) ; Return the last k lines of file
{
Loop Read, %file%
{
i := Mod(A_Index,k)
L%i% = %A_LoopReadLine%
}
L := L%i%
Loop % k-1
{
IfLess i,1, SetEnv i,%k%
i-- ; Mod does not work here
L := L%i% "`n" L
}
Return L
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment