LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   About the -print option in find command (https://www.linuxquestions.org/questions/linux-newbie-8/about-the-print-option-in-find-command-912147/)

the_gripmaster 11-06-2011 06:59 AM

About the -print option in find command
 
Is there a difference between

Code:

find / -iname "*.mp3"
and

Code:

find / -iname "*.mp3" -print
Both give the same output.

I RTFM and could not find any clear explanation regarding -print option, whether it is a default parameter. (Please note that my question is not related to the difference between -print and -print0.)

Thanks.

catkin 11-06-2011 07:41 AM

From the find man page (in the OPTIONS section preamble): "If no expression is given, the expression -print is used".

colucix 11-06-2011 07:47 AM

Indeed it is a default and you can omit it, but there are some cases where it is necessary to specify it, for example in conjunction with -prune. The output of the two following commands differs:
Code:

find /home -wholename /home/colucix -prune
and
Code:

find /home -wholename /home/colucix -prune -o -print

David the H. 11-06-2011 01:15 PM

Another example, and a more detailed explanation, can be found at the end of this page:

http://mywiki.wooledge.org/UsingFind


All times are GMT -5. The time now is 09:33 PM.