bash:find_files_with_modified_dates_in_the_future_and_fix
Sometimes, when working on a new machine or a machine with a screwy clock or incorrect TZ you can then have files modified in the future which breaks some things.
To find the files modified in the future use
find ./ -type f -newermt "1 days"
Now to fix the files to NOW use
find ./ -type f -newermt "5 days"|xargs touch
You can use -d with touch to specify the date you want to use instead of now.
How about finding all files that have not been modified for more than 20 years?
find ./ -type f -mtime +7300
The +7300 is 20*365 or 20 years. If you wanted to delete these files then -delete will do it. If you wanted to archive these files then output the filenames to a file with > filename.txt and then either sed that into cp commands or feed it into the cp.
/home/gen.uk/domains/wiki.gen.uk/public_html/data/pages/bash/find_files_with_modified_dates_in_the_future_and_fix.txt · Last modified: 2019/05/17 09:45 by genadmin