LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-28-2009, 09:53 PM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,166
Blog Entries: 4

Rep: Reputation: 131Reputation: 131
Question on Find Command: - Vs +


Been using Linux for sometime and realized that you have the following option:

find / -name foo.txt (this allows a person to find all of the files)

Vs

find / +name foo.txt (this allows a person to find any of the files)


My sticking point is what is the difference between all Vs any?

thanks
 
Old 04-28-2009, 10:29 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hmmm ... I'm curious: where did you stumble across this?
While it seems to work (albeit with - let's say - unexpected
results), I can't seem to find this invocation referenced in
finds documentation?


Cheers,
Tink
 
Old 04-28-2009, 10:44 PM   #3
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Output of ls in test directory

Code:
ls
test1  test2
output of find ./ -name test1

Code:
find ./ -name test1
./test1
output of find ./ +name test1
Code:
find ./ +name test1
./
./test1
./test2
find: +name: No such file or directory
test1
output of find ./
Code:
find ./
./
./test1
./test2
In short, I think all you are doing is generating an error that results in find invocating three times.

Are you seeing different results?

Last edited by billymayday; 04-28-2009 at 10:46 PM.
 
Old 04-28-2009, 10:46 PM   #4
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,166
Blog Entries: 4

Original Poster
Rep: Reputation: 131Reputation: 131
Ok, my goof.

I'm studying for my Linux+, and I'm using the following book:

Linux+ Study Guide, 3rd Edition by Roderick W Smith.

I found this in chp 2 and didn't see that you need to also use, -perm.

I then checked the man page for find and now it makes sense:

Code:
-perm mode
      
File’s  permission  bits are exactly mode (octal or symbolic).  Since an exact match is required, if you want
to use this form for symbolic modes, you may have to specify a rather complex mode string.  For example -perm
g=w  will  only  match files which have mode 0020 (that is, ones for which group write permission is the only
permission set).  It is more likely that you will want to use the ‘/’ or ‘-’ forms, for example  -perm  -g=w,
which matches any file with group write permission.  See the EXAMPLES section for some illustrative examples.

Code:
-perm +mode
              
Deprecated, old way of searching for files with any of the permission bits in mode set.  You should use -perm
/mode instead. Trying to use the ‘+’ syntax with symbolic modes will yield surprising results.  For  example,
‘+u+x’ is a valid symbolic mode (equivalent to +u,+x, i.e. 0111) and will therefore not be evaluated as -perm
+mode but instead as the exact mode specifier -perm mode and so it matches files with exact permissions  0111
instead  of  files  with any execute bit set.  If you found this paragraph confusing, you’re not alone - just
use -perm /mode.  This form of the -perm test is deprecated because  the  POSIX  specification  requires  the
interpretation of a leading ‘+’ as being part of a symbolic mode, and so we switched to using ‘/’ instead.

-perm +mode is the old way of search for any of the permission bits in
mode set.

thanks
 
Old 04-29-2009, 02:44 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
'-' and '+' also apply to timestamps (ctime, mtime, atime) in find cmd. See man page.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Question about find command centosfan Linux - Server 2 11-10-2008 08:36 PM
Question about find command + recognizing filenames with spaces 200mg Linux - General 3 02-22-2008 03:37 PM
fgrep or find command question. swamprat Linux - Newbie 2 02-13-2008 02:26 PM
Question on find command rytrom Linux - Newbie 3 08-07-2003 03:14 AM
Find Command - Basic Question tlb04 Linux - General 3 05-06-2003 09:45 PM


All times are GMT -5. The time now is 12:10 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration