Linux command find -print. When to I need this option?

What is the difference between:
find . -name "*.txt" and find . -name "*.txt" -print ?

I mean what is the use of print in find. I see that it prints the results anyway so why is this option available?

1 Answer

In very old versions of find, -print wasn't implicit so was required.

Nowadays, it is the default action but is still useful when combined with -prune to avoid the default action to encompass the pruning. eg:

This won't print files named foo under /tmp:

find /tmp -name foo -prune -o -type f -print

This will:

find /tmp -name foo -prune -o -type f
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like