1

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.

mau5
  • 179
  • 1
  • 3
  • 8

1 Answers1

0

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
l'L'l
  • 44,951
  • 10
  • 95
  • 146