LinuxQuestions.org

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

the_gripmaster 11-06-2011 07: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 08: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 08: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 02: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 12:15 PM.