home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
utlos2.zip
/
Doc
/
pattern.doc
< prev
next >
Wrap
Text File
|
1997-10-24
|
6KB
|
125 lines
$Id: pattern.doc 1.6 1997/10/25 01:59:10 brian Exp $
pattern.doc : Filename pattern matching
By: Brian E. Yoder
(c) Copyright International Business Machines Corporation 1997
All rights reserved.
========================================================================
A dot is just another character. "*" means "all files" on all platforms
========================================================================
To the ls and other commands in this package, a filename is just a
string of characters. The dot has no special meaning (it's just another
character), so there is no concept of a "file extension". This is
consistent with Win32, OS/2's HPFS, and with Unix filesystems.
The pattern * matches any filename. The pattern *.* matches any filename
that contains a dot. Note that *.* will not match a filename that
doesn't contain a dot! This is important to remember! It is the one
Unix-like convention that has been carried over.
========================================================================
Path Separator : Both \ and / are accepted
========================================================================
Either a \ (backslash) or / (forward slash) character may be used as a
filename path separator on the command lines of these utilities.
The \ (backslash) is traditionally used for the DOS, Windows, and OS/2
platforms and is required by the native commands for those platforms.
The / (forward slash) is the only path separator used for Unix platforms
and is often required by the DOS, Windows, and OS/2 ports of the popular
Unix-like GNU tools.
However, the DOS, Windows, and OS/2 programming interfaces allow both
characters to be used as path separators. Therefore, the commands in
this package are designed to accept either character as a path separator
for maximum convenience no matter which platform or convention you need
or prefer.
========================================================================
Patterns : Lots better than DOS, even better than Win32 and OS/2
========================================================================
A filename can contain one or more of the following patterns. Note that
patterns are not case-sensitive:
Pattern What it matches Examples
------- ------------------------------ ----------------------------
* Matches any string, including *ab* matches ab, blab,
the null string. and babies.
* matches any string,
including TEMP, WINDOWS,
makefile, or myfile.c.
? Matches any single character. ab?c matches any filename
that is 4 characters
long, begins with ab,
and ends with c.
. Remember that "." matches a dot *.* matches myfile.c,
config.sys, and zip.hlp
*.* does NOT match TEMP,
WINDOWS, or makefile.
This is because these
names do not contain a
dot character.
[...] Matches any one of the [ABC]* matches any filename
enclosed characters. that begins with A, B, or C.
[.-.] Matches any character [A-Z]* matches any filename
between the enclosed pair, that begins with a letter.
inclusive (range).
[A-LN-Z]* matches any filename
that doesn't begin with M.
[!...] Matches any single character [!XYZ]* matches any filename
except one of those enclosed. that does not begin with
X, Y, or Z.
Put a backslash before the following characters if they are part of the
filename to be matched. This removes their special meaning:
[ ] { } !
========================================================================
In addition ...
========================================================================
Enclosed characters can be combined with ranges. Thus, [ABCM-Z]* matches
any filename that begins with A, B, C, or M through Z.
Additionally, any pattern may be followed by:
{m} Matches exactly m occurrences of the pattern.
{m,} Matches at least m occurrences of the pattern.
{m,n} Matches at least m but no more than n occurrences of the pattern.
where: m and n must be integers from 0 to 255, inclusive.
========================================================================
Examples
========================================================================
The pattern [A-Z][0-9A-Z.]{0,} matches any filename that begins with a
letter that is followed only by letters or numbers, and may have a dot
(DOS or OS/2 8.3 extension).
The pattern [!.]{1,} matches any filename that does not contain a dot.
Literally, the pattern means: Match any name that contains one or more
occurrences of any character that is not a dot.
The pattern *TXT* matches any filename that contains the string "TXT",
either in the beginning, at the end, or in the middle.
Again, the pattern * matches any filename. The pattern *.* matches any
filename that contains a dot. Note that *.* will not match a filename
that doesn't contain a dot! This is important to remember! It is the one
Unix-like convention that has been carried over.