Irina Rapoport Irina Rapoport - 28 days ago 4
Bash Question

Why is not my `find` command working?

What is this and why is this not listing files that have "idea" in their names?

/Applications/$ find . "*idea*" -exec echo aaa {} \; | head
aaa .
aaa ./_CodeSignature
aaa ./_CodeSignature/CodeResources
aaa ./bin
aaa ./bin/fsnotifier
aaa ./bin/
aaa ./bin/
aaa ./bin/libbreakgen.dylib
aaa ./bin/libbreakgen.jnilib
aaa ./bin/libbreakgen64.dylib
find: *idea*: No such file or directory


You are missing the -name test:

find . -name "*idea*" -exec echo aaa {} \;

Without -name:

find . "*idea*" -exec echo aaa {} \;

is find-ing all files/directories, on current directory (.), and file/directory matched by *idea* in the current directory, recursively. Presumably, there is no file/directory with idea in their names in the current directory, hence the error regarding *idea*.

As a side note, if you are looking for only files, add -type f:

find . -name "*idea*" -type f -exec echo aaa {} \;