Originally Posted by vbekker
rm -rf $(ls -1t | tail -n +7)
As already stated by GrapefruiTgirl, this won't work with "special" files.
Try adding ls's -Q option (puts quotes around the filenames):
rm -rf $(ls -1Qt | tail -n +7)
Hope this helps.
And it seems I was a bit slow in replying ;-)