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

前端 未结 3 1350
庸人自扰
庸人自扰 2020-12-10 05:43

I have a folder which contains some subversion revision checkouts (these are checked out when running a capistrano deployment recipe).

what I want to do really is t

3条回答
  •  感情败类
    2020-12-10 06:45

    Below is a useful way of doing the task.......!!

    for Linux and HP-UX:

    ls -t1 | tail -n +50 | xargs rm -r # to leave latest 50 files/directories.

    for SunOS:

    rm `(ls -t |head -n 100; ls)|sort|uniq -u`

提交回复
热议问题