What's the name for the
symbol and what is its significance?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
*.*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).
*.*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
dotglob shell option can be set or the
GLOBIGNORE variable can be set appropriately, but this is another question!
glob in bash, Below I have quoted from bash manual:
Matches any string, including the null string. When the globstar shell option is enabled, and
*is used in a pathname expansion context, two adjacent
*sused as a single pattern will match all files and zero or more directories and subdirectories. If followed by a
/, two adjacent
*swill match only directories and subdirectories.
In this case,
*.* match any files that contain a dot
. in its name.
You can see more details here.
* 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:
You might also want to refer to Filename Expansion in the manual.
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.
* 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).
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
*.? 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.)
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