Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

raison

macrumors member
Original poster
Nov 13, 2009
83
4
I am trying to use the find tool to look for files that contains the question mark in their names. I am using:

Code:
find . -name *\?* -print

But that is displaying all the files in the current directory. What is the proper way?
 

fat jez

macrumors 68020
Jun 24, 2010
2,083
614
Glasgow, UK
the . in between your find command and -name means current working directory, which is why it's only looking there, i.e.

. current working directory
.. parent directory
 

mfram

Contributor
Jan 23, 2010
1,307
343
San Diego, CA USA
You need to put single quotes around the filename part:

Code:
imac:~> find . -name '*\?*'
./bin/foo?

imac:~> find . -name *\?*
find: No match.

The reason is because without the single quotes the shell will expand your *\?* in place which is not what you want.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.