Find and move old files

A very simple script to find all files modified within the 60 last days and move them to a specific directory.

find . -type f -mtime -60 | xargs -i  cp {} /tmp/archiveCopy/

Note the sign in front of 60. Without it, we would only retrieve the files modified 60 day ago. We could use + to retrieve files modified before this date.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.