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-mtime
I need the-print
? But then I don't understand why in this particular case, the results are the same. Do I need-print
here or not? – Grateful Jan 29 '23 at 09:50-print
action is performed on all files for which the whole expression is true, unless it contains an action other than-prune
or-quit
. Actions which inhibit the default-print
are-delete
,-exec
,-execdir
,-ok
,-okdir
,-fls
,-fprint
,-fprintf
,-ls
,-print
and-printf
." – rickhg12hs Jan 29 '23 at 09:58-print
is used by default for everything unless you have another option... So, does that mean adding-mtime
then requires us to add-print
additionally... 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-print
is added or not? Very very confusing!!! – Grateful Jan 29 '23 at 10:03-mtime
is not in the set of actions "-delete
,-exec
,-execdir
,-ok
,-okdir
,-fls
,-fprint
,-fprintf
,-ls
,-print
and-printf
". In fact,-mtime
is not an action. – rickhg12hs Jan 29 '23 at 10:11-print
with-mtime
or 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-print
is used by default unless there's another action.-mtime
isn'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 \; -print
and remove the-print
– ilkkachu Jan 29 '23 at 11:19