2

I just run a command to "find and delete files & folder older than 100 days" on a folder, and got the following:

$ find . * -mtime +100 -delete
find: May_01_2015: No such file or directory
find: May_02_2015: No such file or directory
find: May_03_2015: No such file or directory
find: May_04_2015: No such file or directory
find: May_05_2015: No such file or directory
find: May_06_2015: No such file or directory
find: May_07_2015: No such file or directory
find: May_08_2015: No such file or directory
find: May_09_2015: No such file or directory
find: May_10_2015: No such file or directory

The folder names are correct (they should be deleted), but why is it complaining that it could not find those folders? (they were there)


Also, it's interesting, when I do:

$ find "$(pwd)" * -mtime +200 -print

I sometimes see the same file listed twice. I wonder if that's the reason. Why is it going through the same file twice?

4

You don't need .* with find and the space between . and * is often a mistake, since the * will expand to every entry in the current directory, and tell find to use that as a path to search. That's also why your other find sometimes shows files twice. If the j$(pwd) actually matches a file it will also be matched by *.

So your delete one will probably do better as:

find . -mtime +100 -delete

Though you might want to do it with -print to make sure you're getting what you want before deleting them of course.

-1
100 Days = 144,000 Minutes = 144000 Minutes -daystart Measure times (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) from the beginning of today rather than from 24 hours ago. This option only affects tests which appear later on the command line. find "$(pwd)" -daystart -amin +144000 -exec ls -ltrio {} +
  • You do not explain why atime is relevant. And your answer cannot be cross-checked 'cause you do not provide an example of how to create the files to reproduce your output. – grochmal Jan 19 '17 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.