MPE/iX Shell and Utilities Reference Manual, Vol 2

sh(1) MPE/iX Shell and Utilities sh(1)
Note: The shell performs the implicit redirections needed for pipelines before performing any
explicit redirections.
File Name Generation
The characters *?[ are called glob characters or wild card characters. If an unquoted argu-
ment contains one or more glob characters, the shell processes the argument for file name gen-
eration. The glob characters are part of glob patterns which represent file and directory
names. These patterns are similar to regular expressions, but differ in syntax, since they are
intended to match file names and words (not arbitrary strings). The special constructions that
may appear in glob patterns are:
? Matches exactly one character of a file name, except for the separator character /
and a . at the beginning of a file name. ? only matches an actual file name character
and does not match nonexistent characters at the end of the file name. ? is analogous
to the metacharacter . in regular expressions.
Matches zero or more characters in a file name, subject to the same restrictions as ?.
* is analogous to the regular expression .*.
[chars]
Defines a class of characters; the glob pattern matches any single character in the
class. A class may contain a range of characters by writing the first character in the
range, a dash , and the last character. For example, [A–Za–z], in the
POSIX locale,
stands for all the uppercase and lowercase letters. If you want a literal character in
the class, put it as the first or last character inside the brackets. If the first character
inside the brackets is exclamation mark (!), the pattern matches any single character
that is not in the class.
Some sample patterns are:
[!a-f]*.c
matches all .c files beginning with something other than the letters a through f.
/???/?.?
matches all files which are under the root directory in a directory that has a three
letter name, and which have a base name containing one character followed by a .
followed by another single character.
*/*.[chyl]
matches all .c, .h, .y, and .l files in a subdirectory of the current directory.
˜mks/*.ksh
matches all shell scripts in the home directory of user mks (see Directory Substitu-
tion for the use of ˜).
If no files match the pattern, sh leaves the argument untouched. If the set option –f or –o
noglob is in effect, the shell does not perform file name generation.
1-538 Commands and Utilities