find: unknown predicate
Make sure you quote the patterns you provide to find
, otherwise the shell may expand them if there are matching files in the current dir.
find /some/dir -name *.jpg # bad
find /some/dir -name "*.jpg" # good
See http://mywiki.wooledge.org/UsingFind.
Related videos on Youtube

yorch
Updated on September 18, 2022Comments
-
yorch 8 months
This is probably not a Ubuntu question as such, but a Linux one instead, still hope some Linux user out there can help me understand this.
I'm trying to use the find command to look for some files an a directory tree.
Unfortunately some of the files are named beginning with a dash, like
-000.jpg
,-002.jpg
,00n.jpg
and so on. However, every time that the command locates one of the files named that way, it just interrupts the process and complains in the following way:find: unknown predicate `-001.jpg'
or whatever the file beginning with a dash is named.
It seems to me that somehow the find command is interpreting the resulting filename as an argument, but I haven't found a way to circumvent this behavior.
Thanks in advance for sharing your wisdom.
-
Eliah Kagan about 11 yearsThis is strange behavior and probably a bug...but I wonder if what's going on is that you have an expression with wildcards in your
find
command itself that is being expanded by the shell into filenames starting with-
(before it is given tofind
). Can you edit your question to add the full and exact text of thefind
command you're issuing, which is producing this problem? -
Christopher B. Adkins about 11 yearsWhat is the exact command line you are using?
-
-
isomorphismes almost 8 yearsI just did
find ~/folder -name "*.png"
and got the error stated in the title. -
geirha almost 8 years@isomorphismes, that line will not produce that error message on its own. It must be caused by other factors. E.g. if you try to put the find command in a variable, then run that variable, that is a plausible way to get that type of error. If that's the case, the solution is simple; don't put commands in variables.
-
isomorphismes almost 8 yearsI accidentally restarted my computer in the last two days and it works now, so I guess I can't reproduce the problem or test it any longer. I can't think of what would have changed but it wasn't using a variable. I just ran the naked line.
-
isomorphismes almost 8 yearsIt may have been that I used
find /some/dir -name="*.jpg"
with a=
instead of a space. HTH some googler.