On Ubuntu 14.04, 64 bit, I have set /lib/modules/4.2.0-27-generic/kernel/drivers to be my current directory. I intend to search all files having net present as a sub-string. If I search with a regex of *net*, only the ./net directory is returned as the search result. However, if I specify exact file name, then only it lists out the relevant file (Useless because not always I know the exact file name to cross check).$ find . -name *net* ./net$ find . -name *usbnet* ./net/usb/usbnet.ko$ pwd/lib/modules/4.2.0-27-generic/kernel/driversWhat mistake am I making?
Why is find not listing matching files when preceded by an asterisk(*)?
shell;find;quoting;wildcards
Because when you use just *net* (without any quoting or escaping), it will be expanded by the shell as the (existing) net file/directory in the current directory before the find command run. So the command becomes:find . -name netAs you can see it is just matching net, so usbnet.ko will not be matched.Also note that, without quoting and escaping, if the pattern does not match (and nullglob and failglob options are disabled), it is treated as is. So for example, for find . -name *net*, if no file name contains net in current directory the pattern find gets is *net*.So to solve the problem, you need to avoid the shell globbing, to do so you can use quoting or escaping the glob patterns:find . -name '*net*' find . -name *net* find . -name \*net\* 