To explain why you see this behaviour:
*.lex is expanded by the shell to all filenames with extension .lex in the current directory, after which the result is passed to "find".
So, if you have a directory with files "1.lex" and "2.lex", the parameters that "find" gets
find . -name 1.lex 2.lex
which is clearly not what you want.
By quoting the "*.lex" (either single or double quotes), you prevent the filename/wildcard expansion.
This means that "find" then gets the parameter "*.lex" literally, which it then uses to filter the names of objects (files/dirs) found.
Originally Posted by bigrigdriver
find . -name: the dot says "this directory". It's that simple. If you want it to recurse into sub-directories, replace the dot (.) with the directory name, such as:
find ~ -name *.lex, where ~ represents your home directory
Sorry, but I disagree with this. "." is a valid directory and doesn't need replacing. "find" always recurses into sub-directories of a given directory (be that ".", ~/, /home/you/ or whatever), unless you limit it using the "-maxdepth" option.