Title: Find wildcard search not working in /etc
Tags: find;wildcards
Question: I have used find command in many directories but when running the following from /etc:
find /etc -name *.conf
it errors out and cannot figure it out. It is only happening with the /etc directory. I can run this exact command from any other directory and works fine. Call this an OCD thing, I just have to know why.
Comment: find: bad option coreadm.conf (btw OS is Solaris 10)

Comment: using the quotes resolved it, but does still leave the question as to why it works everywhere else and have to modify it within /etc

Comment: I can do find /var -name  within /var and not need to modify the find pattern

Comment: I also ran within /etc directory: find /etc -name *s. This also gave an error, but with the file certs. This is resolved using quotes again, but why does /etc directory require the modification and no other directory does

Comment: Always quote wildcards like `"*.conf"`when using them in `find` - else the shell will try to expand them against the current directory *before* calling `find`

Comment: The difference is not related to matches in the directory you run it *against* (in this case `/etc`), it is whether there are any matches in the directory you run it *from* (i.e. your `PWD`)

Comment: add the error msg to question, might give a clue.. is it permission denied?

Comment: try quoting the argument.. `find /etc/ -name '*.conf'` ... the directory you ran it from likely has the file named `coreadm.conf`

Comment: shell processes the text you typed on command line before it is executed... globs will get expanded if it matches file names in current working directory, double quoted strings will be evaluated for command/variable/history substitutions, file redirections and so on.. you see the error only from `/etc` directory because `*.conf` matched the file in that directory named `coreadm.conf`...

Here is the accepted answer: The problem is that the shell expands your option "*.conf" before executing the command.
use find /etc -name "*.conf" instead
Comment for this answer: adding the quotes does allow it to work, but wanting to know why /etc is the *only* directory that requires modification when doing a pattern search with the find command
Comment for this answer: so is it because the search I am doing is .conf? I go into, say, /var and do: find /var -name *s and has no problem finding all words ending in "s". Only the /etc directory requires quotes around the pattern.
Comment for this answer: ahh, I see what you mean now by the contents determine the need for modification of the search
Comment for this answer: Most likely because there is no .conf - file directly in other directories.
Comment for this answer: Try it with a wildcard that matches two files. The shell will then expand this to `find /var -name local mail`(i used `find /var -name *l`)
This has nothing to to with the directory, rather with the contens of that directory

Here is another answer: The metacharacters ('*', ?' and[]') match a `.' at the start of the base name (this is a change in the findutils-4.4.2).  Basically, you just exclude the '.' to get the result your looking for:
find /etc -name *conf
Comment for this answer: It's true GNU `find`'s `-name` used to skip hidden files (and that was fixed in 4.2.2 in 2004, not in 4.4.2) but I can't see what that has to do with this Q&A. In any case, that `*conf` has to be quoted in a Unix shell command line for it not to be expanded as a glob.

{'source': 'StackExchangeDataset', 'subset': 'unix.stackexchange.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 9, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:07/02/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<find><wildcards>', 'Title': 'Find wildcard search not working in /etc', 'ViewCount': 3393, 'id': 374799, 'user_AboutMe': None, 'user_AccountId': 1139202.0, 'user_DisplayName': 'Darwin', 'user_Reputation': 23.0, 'user_Views': 1.0, 'user_id': 238766.0}}