AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
 View Only
  • 1.  Remove files and use an exlude.

    Posted Mon February 14, 2011 07:34 PM

    Originally posted by: kenlee


    Hi,

    I have been trying to use find to remove certain files but also exclude other files similar.

    For instance,

    I am trying to remove all files that end in 1 (eg 3453431 )and am -mtime +8 with a

    find /dir/dir -name "*1" -mtime +8 -exec rm {} \:

    Now in the same directory I also have some files that are named po32321 and I want to keep these files for 30 days. Now the command above will remove the po files that are older than 8 days as it also falls under that criteria.

    My question is how can I exclude these po files from the find /dir/dir -name "*1" -mtime +8 -exec rm {} \: portion of the script and have them delete after the allotted 30 days?

    I have tried many different methods that have been all but useless, i hope someone out there can help.

    Thanks.
    #AIX-Forum


  • 2.  Re: Remove files and use an exlude.

    Posted Tue February 15, 2011 12:07 AM

    Originally posted by: mmveiga


    find /dir/dir -name "1" -a ! -name "po"

    Marcelo.
    #AIX-Forum


  • 3.  Re: Remove files and use an exlude.

    Posted Tue February 15, 2011 12:14 AM

    Originally posted by: mmveiga


    Sorry my previous post was reformatted, breaking into two lines just to avoid the reformatting :

    find /dir/dir -name "*1" \
    -a ! -name "po*"

    Marcelo.
    #AIX-Forum


  • 4.  Re: Remove files and use an exlude.

    Posted Tue February 15, 2011 12:36 AM

    Originally posted by: kenlee


    Thanks a heap Marcelo,

    I think that is ok, I just need to confirm and confirm again that it is all good. You would not believe how close I came to that query, very frustrating.

    Thanks again.
    #AIX-Forum