On 10/13/09, Michael Erickson <m...@quidquam.com> wrote: > 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 > Hi Michael,
Does not work for me, here's my folder SERVER:/backups/git/proy2.git# ls -al total 468828 drwxr-xr-x 2 git root 4096 Oct 13 15:58 . drwxr-xr-x 3 git root 4096 Oct 13 15:08 .. -rw-r--r-- 1 git git 79920654 Oct 13 15:10 proy2.git.2009-10-13_15:10.tgz -rw-r--r-- 1 git git 79922465 Oct 13 15:18 proy2.git.2009-10-13_15:18.tgz -rw-r--r-- 1 git git 79922921 Oct 13 15:27 proy2.git.2009-10-13_15:27.tgz -rw-r--r-- 1 git git 79924387 Oct 13 15:37 proy2.git.2009-10-13_15:37.tgz -rw-r--r-- 1 git git 79924898 Oct 13 15:38 proy2.git.2009-10-13_15:38.tgz -rw-r--r-- 1 git git 79926773 Oct 13 15:54 proy2.git.2009-10-13_15:54.tgz NOW, I just want to keep this two: -rw-r--r-- 1 git git 79924898 Oct 13 15:38 proy2.git.2009-10-13_15:38.tgz -rw-r--r-- 1 git git 79926773 Oct 13 15:54 proy2.git.2009-10-13_15:54.tgz But, the content of this folder change everytime, so I want to let latest two files (by date). thanks, regards, Israel. > This is complicated enough logic that'd I'd write a one-off perl > script or shell function to do it, personally. > > Mike > -- Regards; Israel Garcia -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org