SMB wildcard rules

Andrew Tridgell tridge at
Tue Jul 27 06:23:59 GMT 1999


This is my best guess as to the correct wildcard rules for NT4.0. 

If anyone would like to test/expand these rules then I recommend using
masktest from the 2.0 CVS tree. Using the command line or any
dos/windows program to test these rules is *very* error prone as the
patterns get munged before they hit the wire. What we need is a
precise description of the on-the-wire wildcard rules.

Note that I am not certain that the rules below are complete or
correct, they are just my best guess after a bunch of experimenting.

the special filename '..' is collapsed to '.' before matching

the pattern '.' does not match anything (even the directory '.')

the blank pattern '' matches any filename except '.' and '..'

'*' matches any number of characters (including 0 characters)

'<' matches any number of characters (including 0 characters) except
 when it is the last character in the pattern, in which case it
 doesn't match a '.'

a series of n '?' wildcards matches exactly n characters

a '>.' matches either a '.' or any character followed by '.'

a series of n '>' wildcards matches between 1 and n characters 

a '.' matches a dot

a '"' matches a dot or end-of-string so '*.' doesn't match 'foo' but '*"' does

More information about the samba-technical mailing list