Reputation: 199
Good morning,
I have many files inside directories, subdirectories which I'm now using copy everything inside.
find /tmp/temp/ -name *files.csv -type f -exec cp -u {} /home/dir/Desktop/dir1/ \;
And I was wondering, if there is anyway that I can copy like, copy if the file's modified date is within two days. I don't want to copy if the modification date is 2 days before the current date.
Upvotes: 1
Views: 8284
Reputation: 81
find /source_directory -type f -mtime +N -exec cp {} /destination_directory ;
Replace /source_directory with the directory where your files are located, /destination_directory with the directory where you want to copy the files, and replace N with the number of days.
Upvotes: 0
Reputation: 47284
You can use mtime
within your find command:
find /tmp/temp/ -type f -mtime -2 -name *files.csv -exec cp -u {} /home/dir/Desktop/dir1/ \;
This would copy only files with a modified time within the last two days of the system time.
-mtime n
File's data was last modified n*24 hours ago
Upvotes: 0