Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2005
    Posts
    7

    Unanswered: using the find Command

    Hello again. This time i am trying to use the find command to lookup files that are older than 180days and then remove them. I am having trouble with it.

    Here is what i have:

    find /directory -atime +10?? -exec rm -f {} \;
    ?? not sure what to put there.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    May be "42"?

  3. #3
    Join Date
    Jul 2005
    Posts
    7
    very cute.. No really its like i can not think or something

    I know i want to use the find command followed by the directory path and i know that i want to execute the remove command but i can figure out how to check which files are 180 day old. File structure looks like example: tmp.20040904.log

  4. #4
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Is there a direct relationship between the file name and the modification time (mtime +180)?
    e.g. Can you create a file today with a file name of last week and than do you want to check on the date in the file name?
    If yes you’ll have to strip off the date from the filename
    Then do some date calculations
    or use the stripped filename as input to the touch command to sync the modification time with the filename before executing find.

  5. #5
    Join Date
    Nov 2005
    Posts
    2
    find /directory -mtime +180 -exec rm -f {} \;

    this will delete all files in the directoy older than 180 days is this your requirement?

  6. #6
    Join Date
    Jul 2005
    Posts
    7
    Thanks for the replys when i read the definition for mtime it just did not seem to apply. I went ahead an did it one at a time.. I had to get it done then but it is nice to know what to do next time it happens.. Thanks for your responces as always every one here is very nice and always helpful. I only hope someday i will know enough to help others as well..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •