It may be a duplicate question but i could not find the solution for this i want to copy a last 3 months files from one directory to another directory but i could find only to l
One can also select the exact date and time other than going back to certain amount of days
cp `find . -type f -newermt '18 sep 2016 20:05:00'` FOLDER
Above copies all the files in the directory that were created after 18 september 2016 20:05:00 to the FOLDER (3 months before today :)
Be careful with the symbol for the find command, it is NOT this one: ' it is this, a backtick: ` date selection is with this: '
If you have files with spaces,newlines, tabs or wildcards in their names, you can use either of the solutions from Stéphane Chazelas, first is for GNU, second is for GNU or some BSDs:
find . -type f -newermt '18 sep 2016 20:05:00' -exec cp -t FOLDER {} +
find . -type f -newermt '18 sep 2016 20:05:00' -exec sh -c 'cp "$@" FOLDER' sh {} +