-
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 ;-)
-
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
-
late but, many thanks, it works ;-)
great wiki ;-)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules