Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What does the question mark in this command mean?

find . –type d –name "?d*" –print

I tried to to run it without it but didn't notice any change.

share|improve this question
That is not regular expression, it is shell pattern. (See Find and regex for similar confusion.) – manatwork Mar 27 '13 at 17:48
Your command contains special characters (“–) rather than regular double-quotes and hyphens ("-). Which ones are you actually using on the command line? If the latter, please edit your post to correct. – depquid Mar 27 '13 at 18:23
The specific term for this is called globbing. – bahamat Mar 31 '13 at 5:25

The question mark matches exactly one character in a filename. So,

find -name "c?t"

will match cat and cot but not coat or ct.

For what it's worth, this is a very common convention for filename matching, and can be used in a variety of command line interface contexts, even Windows' cmd.

Removing the question mark should make a difference unless nothing was matched anyway.

share|improve this answer

The pattern "?d*" in find . -type d -name "?d*" -print is interpreted by the find (as is correctly stated by depquid), not by the shell, and will match all the directories that have a second character d even if the first character is a .

For example, if there exist the directories .dad, ada and xd, the find command would print


while the shell command echo ?d* (where the pattern ?d* is interpreted by the shell) would at least print (there would be and the names of any files matching the pattern)

ada xd

On the other hand if there are no directories with a second character d the find would produce no output in contrast to the shell command that would print

share|improve this answer

The question mark is identified by the shell as a single character. In this case the name is specified as any directory with the second character of the directory name 'd', followed by any other characters.

find did not output anything because there were no directory names that matched the -name specification.

share|improve this answer
Strictly speaking, the shell isn't doing matching here; find is. This makes a difference if you have file1 and file2 and try find -name file? instead of find -name "file?", the former matched by the shell and the latter by find. – depquid Mar 27 '13 at 19:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.