GENWiki

Premier IT Outsourcing and Support Services within the UK

User Tools

Site Tools


bash:find_files_with_modified_dates_in_the_future_and_fix

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

bash:find_files_with_modified_dates_in_the_future_and_fix [2019/05/13 16:26] – created genadminbash:find_files_with_modified_dates_in_the_future_and_fix [2019/05/17 09:45] (current) genadmin
Line 1: Line 1:
 +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
 +
 +<code>find ./ -type f -newermt "1 days"</code>
 +
 +Now to fix the files to NOW use
 +
 +<code>find ./ -type f -newermt "5 days"|xargs touch</code>
 +
 +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? 
 +
 +<code>find ./ -type f -mtime +7300</code>
 +
 +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. 

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki