I'm wondering what's the difference between using * and .* in a regex string.

I guess, * stands for "0 to n characters" but I don't see what .* stands for.

For example, what is the difference between: "2013*11*27" and "2013.*11.*27"? If I take a look to

find . -name [pattern]

As pattern I tried : "2013.*11.*25" and it didn't find "2013-11-25" however, with "2013*11*25", it finds it.

Why ? In unix, 0 or n occurences of wildcards is : *, in regex .* so why doesn't it work ?


* stands for 0 or more arbitrary characters in shell wildcard matches.

* stands for 0 or more occurrences of the preceding expression in regex matches.

. stands for single arbitrary character in regex matches.

Thus, * in shell wildcard match is equivalent to .* in regex match.

"2013*11*27" in regex match will match "2013333111111111127" but not "2013-11-27" but if you use it to find files, e.g. as argument to ls, letting the shell handle it as "shell wildcard match" (and not regex) it will capture "2013-11-27" just fine.

*(in your case, the expression is a single character matching exactly that character, 3 and 1 respectively.)


First, you need to separate regexp from unix shell pattern.
In ksh command expect special option, you will use unix pattern.
if you use for example grep -R you will use regexp.

The * in regex synthax mean 0 or n occurences.
The * in unix pattern mean any string and depending on the settings with or without line jump.
If you use regexp .* means any char except jump line 0 or n time
and using * in a regex will match the previous char 0 or n time.

.* in regexp is equivalent of unix pattenr *

find -name use unix pattern so using .* in a pattern stand for finding .ANY_STRING_OR_NO_STRING no any sring.
tu use regexp use
find -regex


  • I'm still missing something. If I do : find . -name [pattern] As pattern I tried : "2013.*11.*25" and it didn't find "2013-11-25" however, with "2013*11*25", it finds it. If I take a look to what you wrote above, in regexp, I should used .* to say "0 or n occurences of wild card" – user1058398 Nov 27 '13 at 10:18
  • ``find -name` use pattern and not regexp so .* in your search stand for 2013.anystring11.anystring225. You must use find -regexp to use regexp instaed pattern – Kiwy Nov 27 '13 at 10:22
  • Ok Thank you. However, by default, grep use regexp ? – user1058398 Nov 27 '13 at 10:31
  • no to use regexp in grep you must provide the argumen -R. You should consider the use of man grep or any man ;) – Kiwy Nov 27 '13 at 10:35
  • Yeah, but actually I thought that in man pages, pattern was used for regexp. But ok thank you. – user1058398 Nov 27 '13 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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