31 Mar
2012
31 Mar
'12
18:23
On 03/31/2012 09:06 PM, Andreas wrote:
Hi,
I'd like to let cron clean up a directory that holds hourly backups. So there are 24 new files every day.
I'd need some scripting that sorts the content of this directory and then removes everything but the 5 newest files.
Is there a howto or even sample code that does this? If your directory contains only files, something like this should work:
rm `ls -St | tail +6` ls -St sorts the directory contents by time and tail +6 prints the file starting from 6th line Regards, -- Mark -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org