LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-06-2011, 06:59 AM   #1
the_gripmaster
Member
 
Registered: Jul 2004
Location: VIC, Australia
Distribution: RHEL, CentOS, Ubuntu Server, Ubuntu
Posts: 364

Rep: Reputation: 38
Question 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.
 
Old 11-06-2011, 07:41 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
From the find man page (in the OPTIONS section preamble): "If no expression is given, the expression -print is used".
 
1 members found this post helpful.
Old 11-06-2011, 07:47 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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
 
1 members found this post helpful.
Old 11-06-2011, 01:15 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

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

http://mywiki.wooledge.org/UsingFind
 
  


Reply

Tags
find



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 05:30 PM
BASH print only first match from 'find' command. SilversleevesX Programming 3 09-15-2010 07:06 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
mtime option in find command ahmedb72 Linux - Newbie 7 06-23-2009 09:48 AM
Use the prune option in find command frznchckn Linux - General 1 06-06-2007 07:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration