Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What's the name for the

*.*

symbol and what is its significance?

share|improve this question
add comment

7 Answers 7

up vote 17 down vote accepted

Interpretation of *.* under old Windows/DOS systems

The significance here is more related to Windows/DOS than to Unix/Linux. On old Windows/DOS sytstems it was a 'wildcard' pattern. Wildcard patterns were used for matching filenames in a similar manner to Unix globs. The *.* wildcard was commonly used to match any file.

As with a Unix glob, the * will match any sequence of characters in a filename, as such * on its own will also match any file. However the reason why *.* will match any filename too is due to differences in the way that these wildcards work. According to this article:

Any characters other than a dot that come after an asterisk have no effect, since the asterisk moves the cursor to position 12, at which point nothing changes the parse state except for a dot, which clears the last three positions and moves the cursor.

This behaviour (somewhat odd from Unix perspective) means that a dot following a * does not actually match a dot, but is just a hackish way to allow you to add more characters to the pattern. This means that adding another * will match anything in these last three positions.

This makes a little more sense when you consider that the syntax was used on DOS and old Windows systems before Windows 95 which required 8.3 filenames. These filenames were only allowed to have one dot and at most three characters following the dot. Most, if not all files on the system would have a three character extension (even though technically a shorter or no extension was allowed), so somehow I guess it made sense to use *.* to match any file (at least from a warped Windowsey logic perspective).

Interpretation of *.* in Unix shells

In Unix shells, as others have pointed out, this represents a 'pathname expansion' or 'glob.' The * does not have any odd jumping to the end behaviour and thus does not lead to characters following it being ignored. *.* pattern will match any filename containing a dot (except at the start). This will definitely not match any file as there are many files on a Unix/Linux system that don't have an extension (or otherwise contain a dot since this is allowed too).

The reason for *.* not matching a dot at the start of filenames on Unix is because putting a dot at the start is how files are 'hidden' and hidden files are excluded from globs by default. To match them in a POSIX shell, a dot needs to be put explicitly at the start of the pattern. In bash the dotglob shell option can be set or the GLOBIGNORE variable can be set appropriately, but this is another question!

share|improve this answer
1  
It should be noted that current Windows versions seem to behave more logically. In particular, "Any characters other than a dot that come after an asterisk have no effect" is not true anymore; at least when filtering files in a standard Open File dialog on Windows 7 by the pattern *7.*, get all files whose last character before the extension is a 7, and with *sa*, I get all files that contain the substring sa anywhere in there filename, and so on. (Accordingly, the article you cite is titled How did wildcards work in MS-DOS? (emphasis added by myself).) –  O. R. Mapper Apr 7 at 6:16
1  
@O.R.Mapper, updated the headers to reflect this. This behaviour is pre Windows 95, which is in the answer (although the header was misleading). –  Graeme Apr 7 at 12:36
add comment

It's glob in bash, Below I have quoted from bash manual:

bash - GNU Bourne-Again SHell

*

Matches any string, including the null string. When the globstar shell option is enabled, and * is used in a pathname expansion context, two adjacent *s used as a single pattern will match all files and zero or more directories and subdirectories. If followed by a /, two adjacent *s will match only directories and subdirectories.

In this case, *.* match any files that contain a dot . in its name.

You can see more details here.

share|improve this answer
add comment

The asterisk * is a glob in shell language. Quoting from Shell Command Language:

The asterisk ( '*' ) is a pattern that shall match any string, including the null string.

However, it doesn't match filenames beginning with a . unless the shell option dotglob is set.

When you use *.*, it matches anything that:

  • does not start with a .
  • contains at least one .

You might also want to refer to Filename Expansion in the manual.

share|improve this answer
add comment

A lot of people coming from Windows think *.* is for all files. On Windows, it is. On UNIX, it is all files that contain at least 1 dot in their name. * by itself works just fine in Windows (dating all the way back to early DOS); however the old textbooks published *.* and it seems to be a hard habit to break.

share|improve this answer
add comment

* is a wildcard used by the shell to perform filename expansion, also known as "globbing". * expands to anything, including nothing (e.g, *.* will match file., etc.). The other common wildcard is ?, which matches any single character.

Do not confuse the function of these wildcards with the use of the same characters in regular expressions (such as those used with grep).

share|improve this answer
add comment

That is star-dot-star — at least, in the DOS (and later, of course, Windows) world. In DOS, the dot . has special magical meaning, because filenames are an eight-character base (later extended, but let's stay old school) and a three-character extension (which defined the file type). In Unix, file type is usually defined by the first two bytes of the file (or other magic), and the extension is informative but doesn't carry much meaning. Except for when this has all gotten blurred.

So, in Unix, there is no special meaning. The asterisk is a "globbing" character in Unix shells and is wildcard for any number of characters (including zero). ? is another common globbing character, matching exactly one of any character.

*.* matches any filenames which contain at least one .. It doesn't have a special name or any meaning any more than *a* or *_*. And *.? would match any files with a dot and exactly one character after that dot. There are also some more complicated extended globbing patterns — see your shell's man page.

The "New Hacker's Dictionary" (an expansion of the old MIT "Jargon File") notes that "star" is the most common name for the * symbol (followed by splat), and I think that's still true in practice, and . is definitely commonly "dot", so, while it doesn't have any intrinsic special meaning as a conglomerated symbol, the sequence is still reasonably called star-dot-star on Unix. (It's just less useful.)

share|improve this answer
    
This might sound strange but thank you for mentioning "star dot star", it's what made this page googleable! –  Score_Under Jul 9 at 12:14
add comment

Here there are actually 2 symbols, asterisk * and dot .. The shells normally only interpret the asterisk as any character, but in regex it would mean a greedy glob. In this case it would match anything that doesn't end or start with a dot, but contains at least one:

somefile.dot # match
.dot.between.words. # match
.onlydotatstart # don't match
onlydotatend. # match
.startandenddot. # don't match
share|improve this answer
1  
Your onlydotatend. case is a match, surely? –  Graeme Apr 5 at 21:05
    
@Graeme nope. touch 'onlydotatend.' && echo *.* doesn't return it –  Braiam Apr 5 at 21:15
1  
Does for me! On both bash and dash. What shell are you using? –  Graeme Apr 5 at 21:19
    
@Graeme zsh, and you are right bash doesn't. –  Braiam Apr 5 at 21:22
    
I just tried this on a vanilla zsh configuration and it works there too. I don't understand how onlydotatend. can't be a match, is there a configuration option that does this? –  Graeme Apr 7 at 12:33
show 1 more comment

Your Answer

 
discard

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.