find question marks in file names

Discussion in 'macOS' started by raison, Aug 6, 2011.

  1. raison macrumors member

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

    find . -name *\?* -print
    But that is displaying all the files in the current directory. What is the proper way?
  2. fat jez macrumors 68000

    fat jez

    Jun 24, 2010
    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
  3. mfram macrumors 65816

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

    imac:~> find . -name '*\?*'
    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.

Share This Page