Re: Delete Files based on Date

From: Rigler, Stephen C. (srigler_at_marathonoil.com)
Date: 03/30/05

  • Next message: Ed Wilts: "Re: Delete Files based on Date"
    To: General Red Hat Linux discussion list <redhat-list@redhat.com>
    Date: Wed, 30 Mar 2005 10:35:37 -0600
    
    

    "find" will help for this.

    Something like:

    find /some/dir \( -type f -a -mtime +5 \) -exec rm -f {} \;

    On Wed, 2005-03-30 at 10:30 -0600, Kelley.Coleman@med.va.gov wrote:
    > I'm somewhat hampered by my OpenVMS experience with this problem. I need a
    > script that will remove all but the latest five files in a folder. There is
    > only one file per day and I want to keep five days worth. OpenVMS had a
    > nice little flag on the dir command (/before=today-5) that I often used for
    > this kind of thing. I'm just not finding anything similar in Linux. I've
    > found how to sort files based on modified date (ls -ltr), but how can I use
    > that to remove the older files?
    >
    > I didn't see anything useful in the rm man page.
    >
    > Kelley Coleman
    > Database Administrator
    > VA Health Administration Center
    > Denver, Colorado
    > 303-331-7521-o
    > 888-732-8802-p
    > 720-319-0454-c
    >

    -- 
    redhat-list mailing list
    unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
    https://www.redhat.com/mailman/listinfo/redhat-list
    

  • Next message: Ed Wilts: "Re: Delete Files based on Date"