I generally know what find ~ –mtime -30 -print does. It finds all the files that have been modified within the last 30 days. However, I can't figure out what -print is doing. Yes, I tried looking at the documentation, and it says it prints the full name followed by a new line. However, removing -print seems to achieve the same results. So what's the difference?
Asked
Active
Viewed 30 times
0
Grateful
- 113
-print. But in this case, because I have-mtimeI need the-print? But then I don't understand why in this particular case, the results are the same. Do I need-printhere or not? – Grateful Jan 29 '23 at 09:50-printaction is performed on all files for which the whole expression is true, unless it contains an action other than-pruneor-quit. Actions which inhibit the default-printare-delete,-exec,-execdir,-ok,-okdir,-fls,-fprint,-fprintf,-ls,-printand-printf." – rickhg12hs Jan 29 '23 at 09:58-printis used by default for everything unless you have another option... So, does that mean adding-mtimethen requires us to add-printadditionally... Since, it is another action? However, if that is the case, I still don't understand why the command in the question gives the same result regardless of whether-printis added or not? Very very confusing!!! – Grateful Jan 29 '23 at 10:03-mtimeis not in the set of actions "-delete,-exec,-execdir,-ok,-okdir,-fls,-fprint,-fprintf,-ls,-printand-printf". In fact,-mtimeis not an action. – rickhg12hs Jan 29 '23 at 10:11-printwith-mtimeor not? So, I can make sense of why they are giving me the same results. Thank you so much!! – Grateful Jan 29 '23 at 10:35-printis used by default unless there's another action.-mtimeisn't an action, just a condition. It doesn't do anything. So, as you saw, you get the printing by default when all you have is-mtime(or other conditions). It's different if you havefind . -mtime -30 -exec true \; -printand remove the-print– ilkkachu Jan 29 '23 at 11:19