On Tue, Oct 13, 2009 at 12:24 PM, Israel Garcia <igalva...@gmail.com> wrote:
> Hi List,
>
> It's a simple  question but difficult to me :-).
>
> How can I delete all files on a folder /xxxx but keeping only the two
> latest (newest)  files?

Here's one way, (warning: this will probably break painfully on
filenames with spaces in them),

ls --sort=time --time=ctime -1 | tail -n +3 | xargs rm -i

This is complicated enough logic that'd I'd write a one-off perl
script or shell function to do it, personally.

Mike


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to