Linux: How To Delete All Files Except Last

Result:

ls -t1 /var/path/to/folder | tail -n +2 | xargs rm -r

Reference:

how-to-delete-all-files-except-the-latest-three-in-a-folder