Hamilton LaboratoriesHamilton C shell 2012User guideLanguage reference

Wildcarding

Oregon Coast

Wildcarding and pattern matching
Previous | Next

Characters Meaning
?

Match any single character, including . but not \ or /.

*

Match any number of characters, including . but not \ or /.

[a-z]

An example range: match any character a through z.

[^a-z]

An example exclusion range: match any character not in the set a through z.

{a,b}c

Alternation: generate both ac and bc, where a, b and c are themselves arbitrarily complex wildcard patterns.

...

Indefinite Directory: match any number of directory levels – zero or more – whatever it takes to make the rest of the pattern match.

Patterns are used both for traditional filename wildcarding in word mode and for examining strings in expression mode. Patterns are nestable arbitrarily and a recursive comparison algorithm is used to guarantee a sensible result no matter how complex the pattern. For example, *r* and *\[a-c]*.[ch] both operate sensibly.

Even drive letters can be wildcarded, e.g., *:program*/Hamilton* works, though it can be very slow if you have a some net use drives that are offline and you haven’t restricted your search with the DRIVEMASK environment variable. If an application like the C shell tries to read from an unavailable network drive, Windows will try to reconnect the drive in order to perform the read. Reconnecting with a machine that’s up and running is quick. But if the machine is offline, it takes several seconds for the network protocols to time out and for Windows to report that.

Filename wildcards can be used wherever a word is expected and will match any filename except . and .. unless it's marked “hidden.” To allow wildcarding to match hidden files, set nonohidden = 1. Quoting the word prevents wildcarding. Since filenames are not case sensitive, filename wildcarding isn't either.

A pattern can also be used to examine a string in a switch statement or with the =~ (pattern matches) and !~ (pattern fails) expression operators. In this context, the pattern must be inside quotes, since otherwise it would be parsed as an expression, with * being viewed as the multiply operator, etc. When examining a string with a pattern that uses alternation, the pattern matches if any of the alternatives matches. When matching strings, case does matter.

When using a pattern to examine a string with =~ or !~ or with a switch, the string being tested is the left operand and the pattern is on the right.

Previous | Next

Getting started with Hamilton C shell

Hamilton C shell, as it first wakes up.

Getting started with Hamilton C shell

A first few commands.

You can set the screen colors to your taste.

You can set the screen colors to your taste.