Hello!
How to find the directory that was changed 7 days ago and delete it completely?
I use the command:
find /folder/folder1/* -mtime +7 -delete But only the contents of directories from folder1 are deleted.
Hello!
How to find the directory that was changed 7 days ago and delete it completely?
I use the command:
find /folder/folder1/* -mtime +7 -delete But only the contents of directories from folder1 are deleted.
This is the deletion of a directory that changed 7 or more days ago:
find /folder/folder1 -type d -mtime +7 | xargs rm -rf If you need exactly 7, then +7 should be replaced by 7 .
rm -rf $(find /folder/folder1 -mtime 7) $(find /folder/folder1 -mtime 7) structure $(find /folder/folder1 -mtime 7) . If there will be a million search results, will bash ... choke ... - de_frag-I{} . If you do this: find /folder/folder1 -type d -mtime +7 | xargs -I{} rm -rf {} find /folder/folder1 -type d -mtime +7 | xargs -I{} rm -rf {} , then rm will be run separately for each search result, not for the entire line. Frankly, I did not test it on large quantities. Therefore, I can not vouch for the answer. - de_fragSource: https://ru.stackoverflow.com/questions/875836/
All Articles