+ Reply to Thread
Results 1 to 3 of 3

Thread: linux script question

  1. #1
    Join Date
    Nov 2006
    Posts
    178

    Default linux script question

    first, maybe we can extend the forums with some extra parts, like caffeecorner, offtopic, or whatever...

    how can i delete all files in a folder which are older than 3 days?

    thx for your answer
    great wiki ;-)

  2. #2
    Join Date
    Feb 2007
    Location
    Paris, France
    Posts
    165

    Default Use the "find" command

    Here is a command I use for deleting old *.tgz files.

    find FOLDER_NAME -name "*.tgz" -prune -type f -mtime +3 -printf "Deleting file : " -print -exec rm -f {} \;

    FOLDER_NAME replace by your real name
    -name "*.tgz" because I want only delete *.tgz files (optional for you)
    -prune because I only want to examine ordinary files, not directories and sub-directories
    -type f because I only want ordinary files
    -mtime +3 because I want files modified since 3 days
    -printf "Deleting file : " -print because I want to display a message with file name
    -exec rm -f {} \; because I want to delete the files corresponding to my selection

    A lot of options still exist. Try "man find" for explanations

  3. #3
    Join Date
    Nov 2006
    Posts
    178

    Default

    late but, many thanks, it works ;-)
    great wiki ;-)

+ Reply to Thread

Posting Permissions

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