If you want to do this through a script or command line, you can do it with tail.
Code:
tail -n 5 $oldfile > $newfile
will create a new file containing only the last 5 lines
Code:
tail -n 5 $oldfile > $newfile && mv $newfile $oldfile
will replace the original with the new file, effectively removing the all but the last 5 lines.
See "man tail" for further information..